29inline namespace multires_displacement_smear_cc {
60 const int grid = grids[i];
64 const int node_vert = node_grid_range[offset];
65 const int vert = grid_range[offset];
85 float weights_accum = 1.0f;
96 const int neighbor_index = neighbor.to_index(key);
99 const float3 &neighbor_limit_surface_disp =
103 if (
math::dot(current_disp_norm, vert_disp_norm) >= 0.0f) {
107 const float disp_interp = std::clamp(
108 -
math::dot(current_disp_norm, vert_disp_norm), 0.0f, 1.0f);
109 interp_limit_surface_disp += neighbor_limit_surface_disp * disp_interp;
110 weights_accum += disp_interp;
113 interp_limit_surface_disp *=
math::rcp(weights_accum);
116 interp_limit_surface_disp;
118 ccg_positions[vert], new_co, tls.
factors[node_vert]);
129 for (const int grid : range) {
130 const MutableSpan grid_limit_positions = limit_positions.slice(
131 bke::ccg::grid_range(key.grid_area, grid));
132 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];
175 subdiv_ccg.positions,
181 const float strength = std::clamp(ss.
cache->
bstrength, 0.0f, 1.0f);
187 bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
190 bke::pbvh::flush_bounds_to_parents(pbvh);
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)
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)
@ BRUSH_SMEAR_DEFORM_PINCH
@ BRUSH_SMEAR_DEFORM_EXPAND
@ BRUSH_SMEAR_DEFORM_DRAG
Object is a sort of wrapper for general info.
constexpr IndexRange index_range() const
void tag_positions_changed(const IndexMask &node_mask)
Span< NodeT > nodes() const
void foreach_index(Fn &&fn) const
const Depsgraph * depsgraph
IndexRange grid_range(const int grid_area, const int grid)
static void calc_node(const Depsgraph &depsgraph, Object &object, const Brush &brush, const float strength, const bke::pbvh::GridsNode &node, LocalData &tls)
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)
static BLI_NOINLINE void eval_all_limit_positions(const SubdivCCG &subdiv_ccg, const MutableSpan< float3 > limit_positions)
MutableSpan< float3 > gather_grids_positions(const SubdivCCG &subdiv_ccg, const Span< int > grids, Vector< float3 > &positions)
void do_displacement_smear_brush(const Depsgraph &depsgraph, const Sculpt &sd, Object &ob, const IndexMask &node_mask)
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)
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))
struct SculptSession * sculpt
blender::ed::sculpt_paint::StrokeCache * cache
blender::Vector< SubdivCCGCoord, 256 > coords
blender::Array< blender::float3 > positions
Vector< float > distances
Vector< float3 > positions
Array< float3 > prev_displacement
struct blender::ed::sculpt_paint::StrokeCache::@479 displacement_smear
Array< float3 > limit_surface_co
float3 last_location_symm
Vector< float3 > positions
Vector< float > distances