60 const int grid = grids[i];
64 const int node_vert = node_grid_range[offset];
68 switch (
brush.smear_deform_type) {
88 float weights_accum = 1.0f;
94 const int neighbor_index = neighbor.
to_index(key);
97 const float3 &neighbor_limit_surface_disp =
101 if (
math::dot(current_disp_norm, vert_disp_norm) >= 0.0f) {
105 const float disp_interp = std::clamp(
106 -
math::dot(current_disp_norm, vert_disp_norm), 0.0f, 1.0f);
107 interp_limit_surface_disp += neighbor_limit_surface_disp * disp_interp;
108 weights_accum += disp_interp;
111 interp_limit_surface_disp *=
math::rcp(weights_accum);
114 interp_limit_surface_disp;
116 ccg_positions[vert], new_co, tls.
factors[node_vert]);
128 for (const int grid : range) {
129 const MutableSpan grid_limit_positions = limit_positions.slice(
130 bke::ccg::grid_range(key.grid_area, grid));
131 BKE_subdiv_ccg_eval_limit_positions(subdiv_ccg, key, grid, grid_limit_positions);
143 for (
const int grid :
node.grids()) {
145 prev_displacement[i] = positions[i] - limit_positions[i];
177 subdiv_ccg.positions,
184 const float strength = std::clamp(ss.
cache->
bstrength, 0.0f, 1.0f);
194 pbvh.tag_positions_changed(node_mask);
195 pbvh.flush_bounds_to_parents();
A BVH for high poly meshes.
Object is a sort of wrapper for general info.
#define PRF_scope(category)
constexpr IndexRange()=default
constexpr int64_t size() const
constexpr IndexRange index_range() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
IndexRange grid_range(const int grid_area, const int grid)
pbvh::Tree * pbvh_get(Object &object)
void update_node_bounds_grids(int grid_area, Span< float3 > positions, GridsNode &node)
static void calc_node(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, const Brush &brush, const float strength, bke::pbvh::GridsNode &node, LocalData &tls)
static BLI_NOINLINE void eval_all_limit_positions(const SubdivCCG &subdiv_ccg, const MutableSpan< float3 > limit_positions)
static BLI_NOINLINE void store_node_prev_displacement(const Span< float3 > limit_positions, const Span< float3 > positions, const CCGKey &key, const bke::pbvh::GridsNode &node, const MutableSpan< float3 > prev_displacement)
void do_displacement_smear_brush(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob, const IndexMask &node_mask)
MutableSpan< float3 > gather_grids_positions(const SubdivCCG &subdiv_ccg, const Span< int > grids, Vector< float3 > &positions)
void calc_factors_common_grids(const Depsgraph &depsgraph, const Brush &brush, const Object &object, Span< float3 > positions, const bke::pbvh::GridsNode &node, Vector< float > &r_factors, Vector< float > &r_distances)
void scale_factors(MutableSpan< float > factors, float strength)
constexpr ParallelGrainSize grain_size(int grain_size)
T dot(const QuaternionBase< T > &a, const QuaternionBase< T > &b)
T interpolate(const T &a, const T &b, const FactorT &t)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG &subdiv_ccg, const SubdivCCGCoord &coord, bool include_duplicates, SubdivCCGNeighbors &r_neighbors)
int CCG_grid_xy_to_index(const int grid_size, const int x, const int y)
const Brush * BKE_paint_brush_for_read(const Paint *paint)
@ BRUSH_SMEAR_DEFORM_EXPAND
@ BRUSH_SMEAR_DEFORM_DRAG
@ BRUSH_SMEAR_DEFORM_PINCH
VecBase< float, 3 > float3
bke::ObjectRuntime * runtime
ed::sculpt_paint::StrokeCache * cache
int to_index(const CCGKey &key) const
SubdivCCGNeighborCoords coords
Array< float3 > positions
SculptSession * sculpt_session
struct blender::ed::sculpt_paint::StrokeCache::@210266372035032112040136174225236171214246130144 displacement_smear
float3 last_location_symm
Vector< float > distances
Vector< float3 > positions
Vector< float > distances
Vector< float3 > positions