24inline namespace multires_displacement_smear_cc {
55 const int grid = grids[i];
59 const int node_vert = node_grid_range[offset];
60 const int vert = grid_range[offset];
83 float weights_accum = 1.0f;
89 const int neighbor_index = neighbor.to_index(
key);
92 const float3 &neighbor_limit_surface_disp =
96 if (
math::dot(current_disp_norm, vert_disp_norm) >= 0.0f) {
100 const float disp_interp = std::clamp(
101 -
math::dot(current_disp_norm, vert_disp_norm), 0.0f, 1.0f);
102 interp_limit_surface_disp += neighbor_limit_surface_disp * disp_interp;
103 weights_accum += disp_interp;
106 interp_limit_surface_disp *=
math::rcp(weights_accum);
109 interp_limit_surface_disp;
111 ccg_positions[vert], new_co, tls.
factors[node_vert]);
122 for (const int grid : range) {
123 const MutableSpan grid_limit_positions = limit_positions.slice(
124 bke::ccg::grid_range(key.grid_area, grid));
125 BKE_subdiv_ccg_eval_limit_positions(subdiv_ccg, key, grid, grid_limit_positions);
136 for (
const int grid :
node.grids()) {
138 prev_displacement[i] = positions[i] - limit_positions[i];
168 subdiv_ccg.positions,
174 const float strength = std::clamp(ss.
cache->
bstrength, 0.0f, 1.0f);
180 bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]);
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)
A BVH for high poly meshes.
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 int64_t size() const
constexpr IndexRange index_range() const
void tag_positions_changed(const IndexMask &node_mask)
Span< NodeT > nodes() const
void flush_bounds_to_parents()
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 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)
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
SubdivCCGNeighborCoords coords
blender::Array< blender::float3 > positions
struct blender::ed::sculpt_paint::StrokeCache::@399 displacement_smear
Array< float3 > prev_displacement
Array< float3 > limit_surface_co
float3 last_location_symm
Vector< float > distances
Vector< float3 > positions
Vector< float > distances
Vector< float3 > positions