87 const float height_rcp =
math::rcp(height);
98 if (local_positions[i].
z >= 0.0f) {
105 const float depth_rcp =
math::rcp(depth);
107 for (
const int i : local_positions.
index_range()) {
115 for (
const int i : local_positions.
index_range()) {
116 if (local_positions[i].
z < 0.0f) {
139 if (!
ELEM(height, 1.0f, 0.0f)) {
141 if (local_positions[i].
z > 0.0f) {
142 factors[i] *= height;
147 if (!
ELEM(depth, 0.0f, 1.0f)) {
149 if (local_positions[i].
z < 0.0f) {
180 const float strength,
186 for (
const int i : local_positions.
index_range()) {
187 factors[i] *= local_positions[i].z;
190 const float3 &offset = -plane_normal * radius * strength;
198 const float3 &plane_normal,
199 const float strength,
234 brush.curve_distance_falloff,
249 position_data.deform(translations, verts);
257 const float3 &plane_normal,
258 const float strength,
291 brush.curve_distance_falloff,
314 const float3 &plane_normal,
315 const float strength,
346 brush.curve_distance_falloff,
370 const float3 &plane_normal,
371 const float3 &plane_center)
382 float3 normal = plane_normal;
383 float3 center = plane_center;
389 const float displace = ss.
cache->
radius * offset * (flip ? -1.0f : 1.0f);
390 center += normal * ss.
cache->
scale * displace;
405 float height =
brush.plane_height;
406 float depth =
brush.plane_depth;
409 switch (
brush.plane_inversion_mode) {
415 std::swap(height, depth);
422 switch (
pbvh.type()) {
452 SubdivCCG &subdiv_ccg = *
object.runtime->sculpt_session->subdiv_ccg;
459 depsgraph, sd,
object,
brush, mat, normal, strength, height, depth,
nodes[i], tls);
471 depsgraph, sd,
object,
brush, mat, normal, strength, height, depth,
nodes[i], tls);
478 pbvh.tag_positions_changed(node_mask);
479 pbvh.flush_bounds_to_parents();
518 return {plane_mask, plane_center, plane_normal};
A BVH for high poly meshes.
Object is a sort of wrapper for general info.
#define PRF_scope(category)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
constexpr int64_t size() const
constexpr IndexRange index_range() const
constexpr int64_t size() const
constexpr IndexRange index_range() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
float3x3 scale(float3x3 mat, float2 scale)
pbvh::Tree * pbvh_get(Object &object)
IndexMask search_nodes(const Tree &pbvh, IndexMaskMemory &memory, FunctionRef< bool(const Node &)> filter_fn)
void update_node_bounds_bmesh(BMeshNode &node)
void update_node_bounds_mesh(Span< float3 > positions, MeshNode &node)
Span< float3 > vert_normals_eval(const Depsgraph &depsgraph, const Object &object_orig)
void update_node_bounds_grids(int grid_area, Span< float3 > positions, GridsNode &node)
void calc_vert_factors(const Depsgraph &depsgraph, const Object &object, const Cache &automasking, const bke::pbvh::MeshNode &node, Span< int > verts, MutableSpan< float > factors)
void calc_grids_factors(const Depsgraph &depsgraph, const Object &object, const Cache &automasking, const bke::pbvh::GridsNode &node, Span< int > grids, MutableSpan< float > factors)
static void calc_bmesh(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, Object &object, bke::pbvh::BMeshNode &node, LocalData &tls, MutableSpan< float > layer_displacement_factor)
static void calc_grids(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, Object &object, const bool use_persistent_base, const Span< float3 > persistent_base_positions, const Span< float3 > persistent_base_normals, bke::pbvh::GridsNode &node, LocalData &tls, MutableSpan< float > layer_displacement_factor)
static BLI_NOINLINE void calc_translations(const Span< float3 > orig_positions, const Span< float3 > orig_normals, const Span< float3 > positions, const Span< float > displacement_factors, const Span< float > factors, const float height, const MutableSpan< float3 > r_translations)
static void calc_faces(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, const MeshAttributeData &attribute_data, const Span< float3 > vert_normals, const bool use_persistent_base, const Span< float3 > persistent_base_positions, const Span< float3 > persistent_base_normals, Object &object, bke::pbvh::MeshNode &node, MutableSpan< float > layer_displacement_factor, const PositionDeformData &position_data)
static void scale_factors_by_height_and_depth(const float height, const float depth, const MutableSpan< float3 > local_positions, const MutableSpan< float > factors)
static void calc_local_distances(const float height, const float depth, const MutableSpan< float3 > local_positions, const MutableSpan< float > distances)
CursorSampleResult calc_node_mask(const Depsgraph &depsgraph, Object &ob, const Brush &brush, IndexMaskMemory &memory)
void do_plane_brush(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, const IndexMask &node_mask, const float3 &plane_normal, const float3 &plane_center)
void fill_factor_from_hide_and_mask(Span< bool > hide_vert, Span< float > mask, Span< int > verts, MutableSpan< float > r_factors)
MutableSpan< float3 > gather_grids_positions(const SubdivCCG &subdiv_ccg, const Span< int > grids, Vector< float3 > &positions)
bool node_in_sphere(const bke::pbvh::Node &node, const float3 &location, const float radius_sq, const bool original)
void gather_bmesh_positions(const Set< BMVert *, 0 > &verts, MutableSpan< float3 > positions)
void apply_hardness_to_distances(float radius, float hardness, MutableSpan< float > distances)
bool node_fully_masked_or_hidden(const bke::pbvh::Node &node)
void filter_distances_with_radius(float radius, Span< float > distances, MutableSpan< float > factors)
void filter_region_clip_factors(const SculptSession &ss, Span< float3 > vert_positions, Span< int > verts, MutableSpan< float > factors)
void clip_and_lock_translations(const Sculpt &sd, const SculptSession &ss, Span< float3 > positions, Span< int > verts, MutableSpan< float3 > translations)
IndexMask gather_nodes(const bke::pbvh::Tree &pbvh, const eBrushFalloffShape falloff_shape, const bool use_original, const float3 &location, const float radius_sq, const std::optional< float3 > &ray_direction, IndexMaskMemory &memory)
void calc_brush_plane(const Depsgraph &depsgraph, const Brush &brush, Object &ob, const IndexMask &node_mask, float3 &r_area_no, float3 &r_area_co)
void apply_translations(Span< float3 > translations, Span< int > verts, MutableSpan< float3 > positions)
float brush_plane_offset_get(const Brush &brush, const SculptSession &ss)
void calc_front_face(const float3 &view_normal, Span< float3 > normals, MutableSpan< float > factors)
void translations_from_offset_and_factors(const float3 &offset, Span< float > factors, MutableSpan< float3 > r_translations)
void calc_local_positions(Span< float3 > vert_positions, Span< int > verts, const float4x4 &mat, const float3 &plane_center, const float3 &view_normal, eBrushFalloffShape falloff_shape, MutableSpan< float3 > local_positions)
void calc_brush_texture_factors(PaintMode paint_mode, const SculptSession &ss, const Brush &brush, Span< float3 > vert_positions, Span< int > vert, MutableSpan< float > factors)
float3 tilt_apply_to_normal(const Object &object, const float4x4 &view_inverse, const float3 &normal, const float2 &tilt, const float tilt_strength)
constexpr ParallelGrainSize grain_size(int grain_size)
T length(const VecBase< T, Size > &a)
CartesianBasis invert(const CartesianBasis &basis)
AxisSigned cross(const AxisSigned a, const AxisSigned b)
MatT from_scale(const VecBase< typename MatT::base_type, ScaleDim > &scale)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
void transform_points(const float4x4 &transform, MutableSpan< float3 > points, bool use_threading=true)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
@ BRUSH_PLANE_INVERT_DISPLACEMENT
@ BRUSH_PLANE_SWAP_HEIGHT_AND_DEPTH
void BKE_brush_calc_curve_factors(eBrushCurvePreset preset, const CurveMapping *cumap, Span< float > distances, float brush_radius, MutableSpan< float > factors)
MatBase< float, 4, 4 > float4x4
BMesh const char void * data
const Brush * BKE_paint_brush_for_read(const Paint *paint)
VecBase< float, 3 > float3
const Set< BMVert *, 0 > & BKE_pbvh_bmesh_node_unique_verts(bke::pbvh::BMeshNode *node)
static MatBase identity()
bke::ObjectRuntime * runtime
ed::sculpt_paint::StrokeCache * cache
Array< float3 > positions
SculptSession * sculpt_session
VArraySpan< bool > hide_vert
std::unique_ptr< auto_mask::Cache > automasking
bool initial_direction_flipped
Vector< float > distances
Vector< float3 > positions
Vector< float3 > local_positions
Vector< float3 > translations
Vector< float > distances
Vector< float3 > positions
Vector< float3 > translations
Vector< float3 > local_positions
void resize(int new_size)