51 for (
float &factor : factors) {
52 factor = std::clamp(factor, 0.0f, 1.0f);
66 const float alpha =
brush.surface_smooth_shape_preservation;
67 const float beta =
brush.surface_smooth_current_vertex;
85 [&](
const int i,
const int pos) {
91 attribute_data.
hide_vert, attribute_data.
mask, verts, factors);
116 for ([[maybe_unused]]
const int iteration :
IndexRange(
brush.surface_smooth_iterations)) {
118 [&](
const int i,
const int pos) {
130 tls.neighbor_offsets,
133 tls.average_positions.resize(verts.
size());
137 tls.laplacian_disp.resize(verts.
size());
152 position_data.deform(translations, verts);
157 [&](
const int i,
const int pos) {
163 all_laplacian_disp.
as_span(), verts, tls.laplacian_disp);
170 tls.neighbor_offsets,
173 tls.average_positions.resize(verts.
size());
176 all_laplacian_disp.
as_span(), neighbors, average_laplacian_disps);
181 laplacian_disp, average_laplacian_disps,
beta, translations);
185 position_data.deform(translations, verts);
192 const Depsgraph &depsgraph,
202 const float alpha =
brush.surface_smooth_shape_preservation;
203 const float beta =
brush.surface_smooth_current_vertex;
215 [&](
const int i,
const int pos) {
244 for ([[maybe_unused]]
const int iteration :
IndexRange(
brush.surface_smooth_iterations)) {
246 [&](
const int i,
const int pos) {
253 tls.average_positions.resize(positions.
size());
256 subdiv_ccg, subdiv_ccg.positions.as_span(), grids, average_positions);
258 tls.laplacian_disp.resize(positions.
size());
278 [&](
const int i,
const int pos) {
285 subdiv_ccg, all_laplacian_disp.
as_span(), grids, tls.laplacian_disp);
287 tls.average_positions.resize(positions.
size());
290 subdiv_ccg, all_laplacian_disp.
as_span(), grids, average_laplacian_disps);
295 laplacian_disp, average_laplacian_disps,
beta, translations);
306 const Depsgraph &depsgraph,
316 const float alpha =
brush.surface_smooth_shape_preservation;
317 const float beta =
brush.surface_smooth_current_vertex;
322 nodes, node_mask, node_offset_data);
327 [&](
const int i,
const int pos) {
356 for ([[maybe_unused]]
const int iteration :
IndexRange(
brush.surface_smooth_iterations)) {
358 [&](
const int i,
const int pos) {
367 tls.average_positions.resize(positions.
size());
371 tls.laplacian_disp.resize(positions.
size());
376 positions, orig_positions, average_positions, alpha, laplacian_disp, translations);
387 [&](
const int i,
const int pos) {
394 all_laplacian_disp.
as_span(), verts, tls.laplacian_disp);
396 tls.average_positions.resize(positions.
size());
403 laplacian_disp, average_laplacian_disps,
beta, translations);
427 "Should only be allocated on the first step");
431 switch (
pbvh.type()) {
448 pbvh.tag_positions_changed(node_mask);
449 pbvh.update_bounds(depsgraph,
object);
A BVH for high poly meshes.
Object is a sort of wrapper for general info.
#define PRF_scope(category)
#define BLI_assert_msg(a, msg)
Span< T > as_span() const
MutableSpan< T > as_mutable_span()
constexpr IndexRange()=default
constexpr int64_t size() const
constexpr Span< T > as_span() const
constexpr int64_t size() const
void foreach_index(Fn &&fn, Mode mode=exec_mode::serial) const
ccl_device_inline float beta(const float x, const float y)
pbvh::Tree * pbvh_get(Object &object)
Span< float3 > vert_normals_eval(const Depsgraph &depsgraph, const Object &object_orig)
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 BLI_NOINLINE void do_surface_smooth_brush_mesh(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, const IndexMask &node_mask, Object &object, const MutableSpan< float3 > all_laplacian_disp)
static BLI_NOINLINE void do_surface_smooth_brush_grids(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, const IndexMask &node_mask, Object &object, const MutableSpan< float3 > all_laplacian_disp)
static BLI_NOINLINE void clamp_factors(const MutableSpan< float > factors)
static BLI_NOINLINE void do_surface_smooth_brush_bmesh(const Depsgraph &depsgraph, const Sculpt &sd, const Brush &brush, const IndexMask &node_mask, Object &object, const MutableSpan< float3 > all_laplacian_disp)
void do_surface_smooth_brush(const Depsgraph &depsgraph, const Sculpt &sd, Object &object, const IndexMask &node_mask)
void average_data_bmesh(const Span< T > src, const Set< BMVert *, 0 > &verts, const MutableSpan< T > dst)
void neighbor_data_average_mesh(const Span< T > src, const GroupedSpan< int > vert_neighbors, const MutableSpan< T > dst)
void surface_smooth_laplacian_step(const Span< float3 > positions, const Span< float3 > orig_positions, const Span< float3 > average_positions, const float alpha, MutableSpan< float3 > laplacian_disp, MutableSpan< float3 > translations)
void surface_smooth_displace_step(const Span< float3 > laplacian_disp, const Span< float3 > average_laplacian_disp, const float beta, const MutableSpan< float3 > translations)
void average_data_grids(const SubdivCCG &subdiv_ccg, const Span< T > src, const Span< int > grids, const MutableSpan< T > dst)
void neighbor_position_average_bmesh(const Set< BMVert *, 0 > &verts, const MutableSpan< float3 > new_positions)
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)
void scatter_data_bmesh(Span< T > node_data, const Set< BMVert *, 0 > &verts, MutableSpan< T > dst)
void gather_bmesh_positions(const Set< BMVert *, 0 > &verts, MutableSpan< float3 > positions)
void calc_brush_strength_factors(const StrokeCache &cache, const Brush &brush, Span< float > distances, MutableSpan< float > factors)
void gather_data_grids(const SubdivCCG &subdiv_ccg, Span< T > src, Span< int > grids, MutableSpan< T > node_data)
void vert_random_access_ensure(Object &object)
void apply_hardness_to_distances(float radius, float hardness, MutableSpan< float > distances)
GroupedSpan< int > calc_vert_neighbors(OffsetIndices< int > faces, Span< int > corner_verts, GroupedSpan< int > vert_to_face, Span< bool > hide_poly, Span< int > verts, Vector< int > &r_offset_data, Vector< int > &r_data)
void filter_distances_with_radius(float radius, Span< float > distances, MutableSpan< float > factors)
int vertex_count_get(const Object &object)
void filter_region_clip_factors(const SculptSession &ss, Span< float3 > vert_positions, Span< int > verts, MutableSpan< float > factors)
void gather_data_bmesh(Span< T > src, const Set< BMVert *, 0 > &verts, MutableSpan< T > node_data)
void orig_position_data_gather_bmesh(const BMLog &bm_log, const Set< BMVert *, 0 > &verts, MutableSpan< float3 > positions, MutableSpan< float3 > normals)
bool stroke_is_first_brush_step(const StrokeCache &cache)
void scale_translations(MutableSpan< float3 > translations, Span< float > factors)
void scale_factors(MutableSpan< float > factors, float strength)
void clip_and_lock_translations(const Sculpt &sd, const SculptSession &ss, Span< float3 > positions, Span< int > verts, MutableSpan< float3 > translations)
void scatter_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
void calc_brush_distances(const SculptSession &ss, Span< float3 > vert_positions, Span< int > vert, eBrushFalloffShape falloff_shape, MutableSpan< float > r_distances)
OffsetIndices< int > create_node_vert_offsets(Span< bke::pbvh::MeshNode > nodes, const IndexMask &node_mask, Array< int > &node_data)
void apply_translations(Span< float3 > translations, Span< int > verts, MutableSpan< float3 > positions)
OrigPositionData orig_position_data_get_mesh(const Object &object, const bke::pbvh::MeshNode &node)
void gather_data_mesh(Span< T > src, Span< int > indices, MutableSpan< T > dst)
OrigPositionData orig_position_data_get_grids(const Object &object, const bke::pbvh::GridsNode &node)
void calc_front_face(const float3 &view_normal, Span< float3 > normals, MutableSpan< float > factors)
void calc_brush_texture_factors(PaintMode paint_mode, const SculptSession &ss, const Brush &brush, Span< float3 > vert_positions, Span< int > vert, MutableSpan< float > factors)
void scatter_data_grids(const SubdivCCG &subdiv_ccg, Span< T > node_data, Span< int > grids, MutableSpan< T > dst)
OffsetIndices< int > create_node_vert_offsets_bmesh(Span< bke::pbvh::BMeshNode > nodes, const IndexMask &node_mask, Array< int > &node_data)
constexpr ParallelGrainSize grain_size(int grain_size)
CCGKey BKE_subdiv_ccg_key_top_level(const SubdivCCG &subdiv_ccg)
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)
ed::sculpt_paint::StrokeCache * cache
VArraySpan< bool > hide_poly
VArraySpan< bool > hide_vert
std::unique_ptr< auto_mask::Cache > automasking
Array< float3 > surface_smooth_laplacian_disp
Vector< float > distances
Vector< float3 > positions
Vector< float3 > translations
Vector< int > neighbor_data
Vector< float3 > average_positions
Vector< float > distances
Vector< int > neighbor_offsets
Vector< float3 > positions
Vector< float3 > laplacian_disp
Vector< float3 > translations
void resize(int new_size)