diff --git a/source/blender/blenkernel/BKE_paint_bvh.hh b/source/blender/blenkernel/BKE_paint_bvh.hh index b7d7679d84e..5dd130fc725 100644 --- a/source/blender/blenkernel/BKE_paint_bvh.hh +++ b/source/blender/blenkernel/BKE_paint_bvh.hh @@ -226,9 +226,6 @@ class Tree { /** Memory backing for #Node::prim_indices. Without an inline buffer to make #Tree movable. */ Array prim_indices_; - public: - std::variant, Vector, Vector> nodes_; - /** * If true, the bounds for the corresponding node index is out of date. * \note Values are only meaningful for leaf nodes. @@ -250,6 +247,9 @@ class Tree { */ BitVector<> visibility_dirty_; + public: + std::variant, Vector, Vector> nodes_; + pixels::PBVHData *pixels_ = nullptr; std::unique_ptr draw_data; @@ -273,7 +273,7 @@ class Tree { Type type() const { - return this->type_; + return type_; } /** @@ -302,6 +302,26 @@ class Tree { */ void tag_attribute_changed(const IndexMask &node_mask, StringRef attribute_name); + /** + * Run the last step of the BVH bounds recalculation process, propagating updated leaf node + * bounds to their parent/ancestor inner nodes. This is meant to be used after leaf node bounds + * have been computed separately. + */ + void flush_bounds_to_parents(); + + /** + * Recalculate node bounding boxes based on the current coordinates. Calculation is only done for + * affected nodes that have been tagged by #PBVH::tag_positions_changed(). + */ + void update_bounds(const Depsgraph &depsgraph, const Object &object); + void update_bounds_mesh(Span vert_positions); + void update_bounds_grids(Span positions, int grid_area); + void update_bounds_bmesh(const BMesh &bm); + + void update_normals(Object &object_orig, Object &object_eval); + + void update_visibility(const Object &object); + private: explicit Tree(Type type); }; @@ -505,15 +525,6 @@ void BKE_pbvh_bmesh_after_stroke(BMesh &bm, blender::bke::pbvh::Tree &pbvh); namespace blender::bke::pbvh { -/** - * Recalculate node bounding boxes based on the current coordinates. Calculation is only done for - * affected nodes that have been tagged by #PBVH::tag_positions_changed(). - */ -void update_bounds(const Depsgraph &depsgraph, const Object &object, Tree &pbvh); -void update_bounds_mesh(Span vert_positions, Tree &pbvh); -void update_bounds_grids(const CCGKey &key, Span positions, Tree &pbvh); -void update_bounds_bmesh(const BMesh &bm, Tree &pbvh); - /** * Copy all current node bounds to the original bounds. "Original" bounds are typically from before * a brush stroke started (while the "regular" bounds update on every change of positions). These @@ -527,7 +538,6 @@ void update_mask_mesh(const Mesh &mesh, const IndexMask &node_mask, Tree &pbvh); void update_mask_grids(const SubdivCCG &subdiv_ccg, const IndexMask &node_mask, Tree &pbvh); void update_mask_bmesh(const BMesh &bm, const IndexMask &node_mask, Tree &pbvh); -void update_visibility(const Object &object, Tree &pbvh); void update_normals(const Depsgraph &depsgraph, Object &object_orig, Tree &pbvh); /** Update geometry normals (potentially on the original object geometry). */ void update_normals_from_eval(Object &object_eval, Tree &pbvh); @@ -602,13 +612,6 @@ void update_node_bounds_mesh(Span positions, MeshNode &node); void update_node_bounds_grids(int grid_area, Span positions, GridsNode &node); void update_node_bounds_bmesh(BMeshNode &node); -/** - * Run the last step of the BVH bounds recalculation process, propagating updated leaf node bounds - * to their parent/ancestor inner nodes. This is meant to be used after leaf node bounds have been - * computed separately. - */ -void flush_bounds_to_parents(Tree &pbvh); - inline Span MeshNode::faces() const { return this->face_indices_; diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 6dd2c4e64c8..056184115f1 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -273,7 +273,7 @@ Tree Tree::from_mesh(const Mesh &mesh) pbvh.tag_positions_changed(nodes.index_range()); - update_bounds_mesh(vert_positions, pbvh); + pbvh.update_bounds_mesh(vert_positions); store_bounds_orig(pbvh); if (!hide_vert.is_empty()) { @@ -457,7 +457,7 @@ Tree Tree::from_grids(const Mesh &base_mesh, const SubdivCCG &subdiv_ccg) pbvh.tag_positions_changed(nodes.index_range()); - update_bounds_grids(key, positions, pbvh); + pbvh.update_bounds_grids(positions, key.grid_area); store_bounds_orig(pbvh); const BitGroupVector<> &grid_hidden = subdiv_ccg.grid_hidden; @@ -536,12 +536,10 @@ Tree::~Tree() void Tree::tag_positions_changed(const IndexMask &node_mask) { - this->bounds_dirty_.resize(std::max(this->bounds_dirty_.size(), node_mask.min_array_size()), - false); - this->normals_dirty_.resize(std::max(this->normals_dirty_.size(), node_mask.min_array_size()), - false); - node_mask.set_bits(this->bounds_dirty_); - node_mask.set_bits(this->normals_dirty_); + bounds_dirty_.resize(std::max(bounds_dirty_.size(), node_mask.min_array_size()), false); + normals_dirty_.resize(std::max(normals_dirty_.size(), node_mask.min_array_size()), false); + node_mask.set_bits(bounds_dirty_); + node_mask.set_bits(normals_dirty_); if (this->draw_data) { this->draw_data->tag_positions_changed(node_mask); } @@ -549,9 +547,8 @@ void Tree::tag_positions_changed(const IndexMask &node_mask) void Tree::tag_visibility_changed(const IndexMask &node_mask) { - this->visibility_dirty_.resize(std::max(this->bounds_dirty_.size(), node_mask.min_array_size()), - false); - node_mask.set_bits(this->visibility_dirty_); + visibility_dirty_.resize(std::max(visibility_dirty_.size(), node_mask.min_array_size()), false); + node_mask.set_bits(visibility_dirty_); if (this->draw_data) { this->draw_data->tag_visibility_changed(node_mask); } @@ -1015,20 +1012,20 @@ static void update_normals_mesh(Object &object_orig, } } -static void update_normals(Object &object_orig, Object &object_eval, Tree &pbvh) +void Tree::update_normals(Object &object_orig, Object &object_eval) { IndexMaskMemory memory; - const IndexMask nodes_to_update = IndexMask::from_bits(pbvh.normals_dirty_, memory); + const IndexMask nodes_to_update = IndexMask::from_bits(normals_dirty_, memory); - switch (pbvh.type()) { + switch (this->type()) { case Type::Mesh: { - update_normals_mesh(object_orig, object_eval, pbvh.nodes(), nodes_to_update); + update_normals_mesh(object_orig, object_eval, this->nodes(), nodes_to_update); break; } case Type::Grids: { SculptSession &ss = *object_orig.sculpt; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - MutableSpan nodes = pbvh.nodes(); + MutableSpan nodes = this->nodes(); IndexMaskMemory memory; const IndexMask faces_to_update = nodes_to_face_selection_grids( subdiv_ccg, nodes, nodes_to_update, memory); @@ -1036,18 +1033,18 @@ static void update_normals(Object &object_orig, Object &object_eval, Tree &pbvh) break; } case Type::BMesh: { - bmesh_normals_update(pbvh, nodes_to_update); + bmesh_normals_update(*this, nodes_to_update); break; } } - pbvh.normals_dirty_.clear_and_shrink(); + normals_dirty_.clear_and_shrink(); } void update_normals(const Depsgraph &depsgraph, Object &object_orig, Tree &pbvh) { BLI_assert(DEG_is_original_object(&object_orig)); Object &object_eval = *DEG_get_evaluated_object(&depsgraph, &object_orig); - update_normals(object_orig, object_eval, pbvh); + pbvh.update_normals(object_orig, object_eval); } void update_normals_from_eval(Object &object_eval, Tree &pbvh) @@ -1057,7 +1054,7 @@ void update_normals_from_eval(Object &object_eval, Tree &pbvh) * their result), and also because (currently) sculpt deformations skip tagging the mesh normals * caches dirty. */ Object &object_orig = *DEG_get_original_object(&object_eval); - update_normals(object_orig, object_eval, pbvh); + pbvh.update_normals(object_orig, object_eval); } void update_node_bounds_mesh(const Span positions, MeshNode &node) @@ -1117,75 +1114,74 @@ static BoundsMergeInfo merge_child_bounds(MutableSpan nodes, return {node.bounds_, update}; } -void flush_bounds_to_parents(Tree &pbvh) +void Tree::flush_bounds_to_parents() { std::visit( [&](auto &nodes) { nodes.first().bounds_ = - merge_child_bounds(nodes.as_mutable_span(), pbvh.bounds_dirty_, 0).bounds; + merge_child_bounds(nodes.as_mutable_span(), bounds_dirty_, 0).bounds; }, - pbvh.nodes_); - pbvh.bounds_dirty_.clear_and_shrink(); + this->nodes_); + bounds_dirty_.clear_and_shrink(); } -void update_bounds_mesh(const Span vert_positions, Tree &pbvh) +void Tree::update_bounds_mesh(const Span vert_positions) { IndexMaskMemory memory; - const IndexMask nodes_to_update = IndexMask::from_bits(pbvh.bounds_dirty_, memory); + const IndexMask nodes_to_update = IndexMask::from_bits(bounds_dirty_, memory); if (nodes_to_update.is_empty()) { return; } - MutableSpan nodes = pbvh.nodes(); + MutableSpan nodes = this->nodes(); nodes_to_update.foreach_index( GrainSize(1), [&](const int i) { update_node_bounds_mesh(vert_positions, nodes[i]); }); - flush_bounds_to_parents(pbvh); + this->flush_bounds_to_parents(); } -void update_bounds_grids(const CCGKey &key, const Span positions, Tree &pbvh) +void Tree::update_bounds_grids(const Span positions, const int grid_area) { IndexMaskMemory memory; - const IndexMask nodes_to_update = IndexMask::from_bits(pbvh.bounds_dirty_, memory); + const IndexMask nodes_to_update = IndexMask::from_bits(bounds_dirty_, memory); if (nodes_to_update.is_empty()) { return; } - MutableSpan nodes = pbvh.nodes(); + MutableSpan nodes = this->nodes(); nodes_to_update.foreach_index(GrainSize(1), [&](const int i) { - update_node_bounds_grids(key.grid_area, positions, nodes[i]); + update_node_bounds_grids(grid_area, positions, nodes[i]); }); - flush_bounds_to_parents(pbvh); + this->flush_bounds_to_parents(); } -void update_bounds_bmesh(const BMesh & /*bm*/, Tree &pbvh) +void Tree::update_bounds_bmesh(const BMesh & /*bm*/) { IndexMaskMemory memory; - const IndexMask nodes_to_update = IndexMask::from_bits(pbvh.bounds_dirty_, memory); + const IndexMask nodes_to_update = IndexMask::from_bits(bounds_dirty_, memory); if (nodes_to_update.is_empty()) { return; } - MutableSpan nodes = pbvh.nodes(); + MutableSpan nodes = this->nodes(); nodes_to_update.foreach_index(GrainSize(1), [&](const int i) { update_node_bounds_bmesh(nodes[i]); }); - flush_bounds_to_parents(pbvh); + this->flush_bounds_to_parents(); } -void update_bounds(const Depsgraph &depsgraph, const Object &object, Tree &pbvh) +void Tree::update_bounds(const Depsgraph &depsgraph, const Object &object) { - switch (pbvh.type()) { + switch (this->type()) { case Type::Mesh: { const Span positions = bke::pbvh::vert_positions_eval(depsgraph, object); - update_bounds_mesh(positions, pbvh); + this->update_bounds_mesh(positions); break; } case Type::Grids: { const SculptSession &ss = *object.sculpt; const SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - update_bounds_grids(key, subdiv_ccg.positions, pbvh); + this->update_bounds_grids(subdiv_ccg.positions, subdiv_ccg.grid_area); break; } case Type::BMesh: { const SculptSession &ss = *object.sculpt; - update_bounds_bmesh(*ss.bm, pbvh); + this->update_bounds_bmesh(*ss.bm); break; } } @@ -1362,27 +1358,27 @@ static void update_visibility_bmesh(const MutableSpan nodes, const In [&](const int i) { node_update_visibility_bmesh(nodes[i]); }); } -void update_visibility(const Object &object, Tree &pbvh) +void Tree::update_visibility(const Object &object) { IndexMaskMemory memory; - const IndexMask node_mask = IndexMask::from_bits(pbvh.visibility_dirty_, memory); + const IndexMask node_mask = IndexMask::from_bits(visibility_dirty_, memory); if (node_mask.is_empty()) { return; } - pbvh.visibility_dirty_.clear_and_shrink(); - switch (pbvh.type()) { + visibility_dirty_.clear_and_shrink(); + switch (this->type()) { case Type::Mesh: { const Mesh &mesh = *static_cast(object.data); - update_visibility_faces(mesh, pbvh.nodes(), node_mask); + update_visibility_faces(mesh, this->nodes(), node_mask); break; } case Type::Grids: { const SculptSession &ss = *object.sculpt; - update_visibility_grids(*ss.subdiv_ccg, pbvh.nodes(), node_mask); + update_visibility_grids(*ss.subdiv_ccg, this->nodes(), node_mask); break; } case Type::BMesh: { - update_visibility_bmesh(pbvh.nodes(), node_mask); + update_visibility_bmesh(this->nodes(), node_mask); break; } } @@ -2356,7 +2352,7 @@ void BKE_pbvh_vert_coords_apply(blender::bke::pbvh::Tree &pbvh, { using namespace blender::bke::pbvh; pbvh.tag_positions_changed(blender::IndexRange(pbvh.nodes_num())); - update_bounds_mesh(vert_positions, pbvh); + pbvh.update_bounds_mesh(vert_positions); store_bounds_orig(pbvh); } diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.cc b/source/blender/blenkernel/intern/pbvh_bmesh.cc index cd19150122b..9b3cfb55a89 100644 --- a/source/blender/blenkernel/intern/pbvh_bmesh.cc +++ b/source/blender/blenkernel/intern/pbvh_bmesh.cc @@ -2262,7 +2262,7 @@ Tree Tree::from_bmesh(BMesh &bm) nodes, cd_vert_node_offset, cd_face_node_offset, nodeinfo, face_bounds, &rootnode, 0); pbvh.tag_positions_changed(nodes.index_range()); - update_bounds_bmesh(bm, pbvh); + pbvh.update_bounds_bmesh(bm); store_bounds_orig(pbvh); threading::parallel_for(nodes.index_range(), 8, [&](const IndexRange range) { diff --git a/source/blender/editors/sculpt_paint/brushes/bmesh_topology_rake.cc b/source/blender/editors/sculpt_paint/brushes/bmesh_topology_rake.cc index 785b979f1f9..62cbc875522 100644 --- a/source/blender/editors/sculpt_paint/brushes/bmesh_topology_rake.cc +++ b/source/blender/editors/sculpt_paint/brushes/bmesh_topology_rake.cc @@ -115,7 +115,7 @@ void do_bmesh_topology_rake_brush(const Depsgraph &depsgraph, }); } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/clay.cc b/source/blender/editors/sculpt_paint/brushes/clay.cc index 591001a108c..b12566ade16 100644 --- a/source/blender/editors/sculpt_paint/brushes/clay.cc +++ b/source/blender/editors/sculpt_paint/brushes/clay.cc @@ -227,7 +227,7 @@ void do_clay_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/clay_strips.cc b/source/blender/editors/sculpt_paint/brushes/clay_strips.cc index 64daa126560..daacc0e36cf 100644 --- a/source/blender/editors/sculpt_paint/brushes/clay_strips.cc +++ b/source/blender/editors/sculpt_paint/brushes/clay_strips.cc @@ -349,7 +349,7 @@ void do_clay_strips_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/clay_thumb.cc b/source/blender/editors/sculpt_paint/brushes/clay_thumb.cc index 4a1294d80fd..cb0d53d67c1 100644 --- a/source/blender/editors/sculpt_paint/brushes/clay_thumb.cc +++ b/source/blender/editors/sculpt_paint/brushes/clay_thumb.cc @@ -257,7 +257,7 @@ void do_clay_thumb_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } float clay_thumb_get_stabilized_pressure(const StrokeCache &cache) diff --git a/source/blender/editors/sculpt_paint/brushes/crease.cc b/source/blender/editors/sculpt_paint/brushes/crease.cc index 7c53d8ac383..59d92145739 100644 --- a/source/blender/editors/sculpt_paint/brushes/crease.cc +++ b/source/blender/editors/sculpt_paint/brushes/crease.cc @@ -258,7 +258,7 @@ static void do_crease_or_blob_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace crease_cc diff --git a/source/blender/editors/sculpt_paint/brushes/draw.cc b/source/blender/editors/sculpt_paint/brushes/draw.cc index a33776cb46b..04970d6fb5e 100644 --- a/source/blender/editors/sculpt_paint/brushes/draw.cc +++ b/source/blender/editors/sculpt_paint/brushes/draw.cc @@ -172,7 +172,7 @@ static void offset_positions(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } void do_draw_brush(const Depsgraph &depsgraph, diff --git a/source/blender/editors/sculpt_paint/brushes/draw_sharp.cc b/source/blender/editors/sculpt_paint/brushes/draw_sharp.cc index 69dd51d0e81..bc10883789b 100644 --- a/source/blender/editors/sculpt_paint/brushes/draw_sharp.cc +++ b/source/blender/editors/sculpt_paint/brushes/draw_sharp.cc @@ -175,7 +175,7 @@ static void offset_positions(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } void do_draw_sharp_brush(const Depsgraph &depsgraph, diff --git a/source/blender/editors/sculpt_paint/brushes/draw_vector_displacement.cc b/source/blender/editors/sculpt_paint/brushes/draw_vector_displacement.cc index 9bd6641e3e3..aaf28e89eac 100644 --- a/source/blender/editors/sculpt_paint/brushes/draw_vector_displacement.cc +++ b/source/blender/editors/sculpt_paint/brushes/draw_vector_displacement.cc @@ -259,7 +259,7 @@ void do_draw_vector_displacement_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/elastic_deform.cc b/source/blender/editors/sculpt_paint/brushes/elastic_deform.cc index 74270ddd097..b0c94946746 100644 --- a/source/blender/editors/sculpt_paint/brushes/elastic_deform.cc +++ b/source/blender/editors/sculpt_paint/brushes/elastic_deform.cc @@ -282,7 +282,7 @@ void do_elastic_deform_brush(const Depsgraph &depsgraph, } break; } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/enhance_details.cc b/source/blender/editors/sculpt_paint/brushes/enhance_details.cc index 610fc12d1fd..1f9a4238e5e 100644 --- a/source/blender/editors/sculpt_paint/brushes/enhance_details.cc +++ b/source/blender/editors/sculpt_paint/brushes/enhance_details.cc @@ -316,7 +316,7 @@ void do_enhance_details_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/grab.cc b/source/blender/editors/sculpt_paint/brushes/grab.cc index 22c0e971c4d..b89a02db829 100644 --- a/source/blender/editors/sculpt_paint/brushes/grab.cc +++ b/source/blender/editors/sculpt_paint/brushes/grab.cc @@ -223,7 +223,7 @@ void do_grab_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } void geometry_preview_lines_update(Depsgraph &depsgraph, diff --git a/source/blender/editors/sculpt_paint/brushes/inflate.cc b/source/blender/editors/sculpt_paint/brushes/inflate.cc index c773c1cd090..f7ac2553b30 100644 --- a/source/blender/editors/sculpt_paint/brushes/inflate.cc +++ b/source/blender/editors/sculpt_paint/brushes/inflate.cc @@ -184,7 +184,7 @@ void do_inflate_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/layer.cc b/source/blender/editors/sculpt_paint/brushes/layer.cc index 84315694fc2..fc6290cc1c1 100644 --- a/source/blender/editors/sculpt_paint/brushes/layer.cc +++ b/source/blender/editors/sculpt_paint/brushes/layer.cc @@ -505,7 +505,7 @@ void do_layer_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/multiplane_scrape.cc b/source/blender/editors/sculpt_paint/brushes/multiplane_scrape.cc index 15544fe0e0c..0d2b4f5aa8a 100644 --- a/source/blender/editors/sculpt_paint/brushes/multiplane_scrape.cc +++ b/source/blender/editors/sculpt_paint/brushes/multiplane_scrape.cc @@ -726,7 +726,7 @@ void do_multiplane_scrape_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } void multiplane_scrape_preview_draw(const uint gpuattr, diff --git a/source/blender/editors/sculpt_paint/brushes/multires_displacement_eraser.cc b/source/blender/editors/sculpt_paint/brushes/multires_displacement_eraser.cc index d91da7b966b..8186d8c8017 100644 --- a/source/blender/editors/sculpt_paint/brushes/multires_displacement_eraser.cc +++ b/source/blender/editors/sculpt_paint/brushes/multires_displacement_eraser.cc @@ -95,7 +95,7 @@ void do_displacement_eraser_brush(const Depsgraph &depsgraph, bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]); }); pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/multires_displacement_smear.cc b/source/blender/editors/sculpt_paint/brushes/multires_displacement_smear.cc index 1e987671de6..ed49173b33d 100644 --- a/source/blender/editors/sculpt_paint/brushes/multires_displacement_smear.cc +++ b/source/blender/editors/sculpt_paint/brushes/multires_displacement_smear.cc @@ -180,7 +180,7 @@ void do_displacement_smear_brush(const Depsgraph &depsgraph, bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]); }); pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/pinch.cc b/source/blender/editors/sculpt_paint/brushes/pinch.cc index a1d7bd9c7a8..8b369012643 100644 --- a/source/blender/editors/sculpt_paint/brushes/pinch.cc +++ b/source/blender/editors/sculpt_paint/brushes/pinch.cc @@ -249,7 +249,7 @@ void do_pinch_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/plane.cc b/source/blender/editors/sculpt_paint/brushes/plane.cc index 1f701d59d8d..51efefba2c0 100644 --- a/source/blender/editors/sculpt_paint/brushes/plane.cc +++ b/source/blender/editors/sculpt_paint/brushes/plane.cc @@ -241,7 +241,7 @@ static void do_plane_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace flatten_cc diff --git a/source/blender/editors/sculpt_paint/brushes/relax.cc b/source/blender/editors/sculpt_paint/brushes/relax.cc index 0b696013352..27aaa0c51f8 100644 --- a/source/blender/editors/sculpt_paint/brushes/relax.cc +++ b/source/blender/editors/sculpt_paint/brushes/relax.cc @@ -209,7 +209,7 @@ static void do_relax_face_sets_brush_mesh(const Depsgraph &depsgraph, bke::pbvh::update_node_bounds_mesh(position_data.eval, nodes[i]); }); pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } BLI_NOINLINE static void calc_factors_grids(const Depsgraph &depsgraph, @@ -337,7 +337,7 @@ static void do_relax_face_sets_brush_grids(const Depsgraph &depsgraph, bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]); }); pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } static void calc_factors_bmesh(const Depsgraph &depsgraph, @@ -435,7 +435,7 @@ static void do_relax_face_sets_brush_bmesh(const Depsgraph &depsgraph, bke::pbvh::update_node_bounds_bmesh(nodes[i]); }); pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } /** \} */ @@ -542,7 +542,7 @@ static void do_topology_relax_brush_mesh(const Depsgraph &depsgraph, bke::pbvh::update_node_bounds_mesh(position_data.eval, nodes[i]); }); pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } BLI_NOINLINE static void calc_topology_relax_factors_grids(const Depsgraph &depsgraph, @@ -653,7 +653,7 @@ static void do_topology_relax_brush_grids(const Depsgraph &depsgraph, bke::pbvh::update_node_bounds_grids(subdiv_ccg.grid_area, positions, nodes[i]); }); pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } static void calc_topology_relax_factors_bmesh(const Depsgraph &depsgraph, @@ -749,7 +749,7 @@ static void do_topology_relax_brush_bmesh(const Depsgraph &depsgraph, bke::pbvh::update_node_bounds_bmesh(nodes[i]); }); pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } /** \} */ diff --git a/source/blender/editors/sculpt_paint/brushes/rotate.cc b/source/blender/editors/sculpt_paint/brushes/rotate.cc index f07b21e3c82..f226d65d47f 100644 --- a/source/blender/editors/sculpt_paint/brushes/rotate.cc +++ b/source/blender/editors/sculpt_paint/brushes/rotate.cc @@ -215,7 +215,7 @@ void do_rotate_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/smooth.cc b/source/blender/editors/sculpt_paint/brushes/smooth.cc index 185da991354..26f813a16de 100644 --- a/source/blender/editors/sculpt_paint/brushes/smooth.cc +++ b/source/blender/editors/sculpt_paint/brushes/smooth.cc @@ -280,7 +280,7 @@ void do_smooth_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::update_bounds(depsgraph, object, pbvh); + pbvh.update_bounds(depsgraph, object); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/snake_hook.cc b/source/blender/editors/sculpt_paint/brushes/snake_hook.cc index 8ece2dc231f..0ac1726dc77 100644 --- a/source/blender/editors/sculpt_paint/brushes/snake_hook.cc +++ b/source/blender/editors/sculpt_paint/brushes/snake_hook.cc @@ -421,7 +421,7 @@ void do_snake_hook_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/surface_smooth.cc b/source/blender/editors/sculpt_paint/brushes/surface_smooth.cc index 79a81d96cf6..025c9c64cf0 100644 --- a/source/blender/editors/sculpt_paint/brushes/surface_smooth.cc +++ b/source/blender/editors/sculpt_paint/brushes/surface_smooth.cc @@ -405,7 +405,7 @@ void do_surface_smooth_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::update_bounds(depsgraph, object, pbvh); + pbvh.update_bounds(depsgraph, object); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/thumb.cc b/source/blender/editors/sculpt_paint/brushes/thumb.cc index 28e0ad2894d..782a4af813e 100644 --- a/source/blender/editors/sculpt_paint/brushes/thumb.cc +++ b/source/blender/editors/sculpt_paint/brushes/thumb.cc @@ -180,7 +180,7 @@ void do_thumb_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/brushes/topology_slide.cc b/source/blender/editors/sculpt_paint/brushes/topology_slide.cc index 2cdd2910bac..d8c693c0399 100644 --- a/source/blender/editors/sculpt_paint/brushes/topology_slide.cc +++ b/source/blender/editors/sculpt_paint/brushes/topology_slide.cc @@ -331,7 +331,7 @@ void do_topology_slide_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint diff --git a/source/blender/editors/sculpt_paint/paint_hide.cc b/source/blender/editors/sculpt_paint/paint_hide.cc index 0446ed8328f..6df0b4bcfd8 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.cc +++ b/source/blender/editors/sculpt_paint/paint_hide.cc @@ -143,7 +143,7 @@ void mesh_show_all(const Depsgraph &depsgraph, Object &object, const IndexMask & attributes.remove(".hide_vert"); bke::mesh_hide_vert_flush(mesh); - bke::pbvh::update_visibility(object, pbvh); + pbvh.update_visibility(object); } void grids_show_all(Depsgraph &depsgraph, Object &object, const IndexMask &node_mask) @@ -171,7 +171,7 @@ void grids_show_all(Depsgraph &depsgraph, Object &object, const IndexMask &node_ BKE_subdiv_ccg_grid_hidden_free(subdiv_ccg); BKE_pbvh_sync_visibility_from_verts(object); - bke::pbvh::update_visibility(object, pbvh); + pbvh.update_visibility(object); multires_mark_as_modified(&depsgraph, &object, MULTIRES_HIDDEN_MODIFIED); } @@ -443,7 +443,7 @@ static void partialvis_update_bmesh_nodes(const Depsgraph &depsgraph, }); pbvh.tag_visibility_changed(node_mask); - bke::pbvh::update_visibility(ob, pbvh); + pbvh.update_visibility(ob); } /** \} */ @@ -735,7 +735,7 @@ static void invert_visibility_mesh(const Depsgraph &depsgraph, hide_poly.finish(); bke::mesh_hide_face_flush(mesh); pbvh.tag_visibility_changed(node_mask); - bke::pbvh::update_visibility(object, *bke::object::pbvh_get(object)); + pbvh.update_visibility(object); } static void invert_visibility_grids(Depsgraph &depsgraph, @@ -1074,7 +1074,7 @@ static void grow_shrink_visibility_grid(Depsgraph &depsgraph, grid_hidden = std::move(last_buffer); pbvh.tag_visibility_changed(node_mask); - bke::pbvh::update_visibility(object, pbvh); + pbvh.update_visibility(object); multires_mark_as_modified(&depsgraph, &object, MULTIRES_HIDDEN_MODIFIED); BKE_pbvh_sync_visibility_from_verts(object); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index db62305787a..3f759a86273 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -540,7 +540,7 @@ void update_cache_variants(bContext *C, VPaint &vp, Object &ob, PointerRNA *ptr) cache->radius_squared = cache->radius * cache->radius; if (bke::pbvh::Tree *pbvh = bke::object::pbvh_get(ob)) { - bke::pbvh::update_bounds(depsgraph, ob, *pbvh); + pbvh->update_bounds(depsgraph, ob); } } diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.cc b/source/blender/editors/sculpt_paint/sculpt_boundary.cc index b39757e79ae..13145d4130e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_boundary.cc +++ b/source/blender/editors/sculpt_paint/sculpt_boundary.cc @@ -1362,7 +1362,7 @@ static void do_bend_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } /** \} */ @@ -1644,7 +1644,7 @@ static void do_slide_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } /** \} */ @@ -1909,7 +1909,7 @@ static void do_inflate_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } /** \} */ @@ -2180,7 +2180,7 @@ static void do_grab_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } /** \} */ @@ -2459,7 +2459,7 @@ static void do_twist_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } /** \} */ @@ -2821,7 +2821,7 @@ static void do_smooth_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index d7ed48a793b..5be16acc0dc 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -1530,7 +1530,7 @@ void do_simulation_step(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } static void cloth_brush_apply_brush_forces(const Depsgraph &depsgraph, @@ -2379,7 +2379,7 @@ static int sculpt_cloth_filter_modal(bContext *C, wmOperator *op, const wmEvent } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); /* Activate all nodes. */ sim_activate_nodes(object, *ss.filter_cache->cloth_sim, node_mask); diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index 864c6c001dc..0f228f41b28 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -1080,7 +1080,7 @@ static int change_visibility_exec(bContext *C, wmOperator *op) undo::push_end(object); - bke::pbvh::update_visibility(object, pbvh); + pbvh.update_visibility(object); islands::invalidate(*object.sculpt); hide::tag_update_visibility(*C); @@ -1483,8 +1483,6 @@ static void edit_modify_coordinates( undo::push_begin(scene, ob, op); undo::push_nodes(depsgraph, ob, node_mask, undo::Type::Position); - pbvh.tag_positions_changed(node_mask); - switch (mode) { case EditMode::FairPositions: edit_fairing(depsgraph, sd, ob, active_face_set, MESH_FAIRING_DEPTH_POSITION, strength); @@ -1496,7 +1494,8 @@ static void edit_modify_coordinates( BLI_assert_unreachable(); } - bke::pbvh::update_bounds(depsgraph, ob, pbvh); + pbvh.tag_positions_changed(node_mask); + pbvh.update_bounds(depsgraph, ob); flush_update_step(C, UpdateType::Position); flush_update_done(C, ob, UpdateType::Position); undo::push_end(ob); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc index 354f3efed7c..d41dd1d9266 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc @@ -2179,10 +2179,10 @@ static void sculpt_mesh_filter_apply(bContext *C, wmOperator *op, bool is_replay bke::pbvh::Tree &pbvh = *bke::object::pbvh_get(ob); pbvh.tag_positions_changed(node_mask); + pbvh.update_bounds(depsgraph, ob); ss.filter_cache->iteration_count++; - bke::pbvh::update_bounds(depsgraph, ob, pbvh); flush_update_step(C, UpdateType::Position); } @@ -2264,7 +2264,7 @@ static void sculpt_mesh_filter_cancel(bContext *C, wmOperator * /*op*/) undo::restore_position_from_undo_step(depsgraph, ob); bke::pbvh::update_normals(depsgraph, ob, *pbvh); - bke::pbvh::update_bounds(depsgraph, ob, *pbvh); + pbvh->update_bounds(depsgraph, ob); } static int sculpt_mesh_filter_modal(bContext *C, wmOperator *op, const wmEvent *event) diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.cc b/source/blender/editors/sculpt_paint/sculpt_pose.cc index bcb95ef3433..67c2d206805 100644 --- a/source/blender/editors/sculpt_paint/sculpt_pose.cc +++ b/source/blender/editors/sculpt_paint/sculpt_pose.cc @@ -2173,7 +2173,7 @@ void do_pose_brush(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } } // namespace blender::ed::sculpt_paint::pose diff --git a/source/blender/editors/sculpt_paint/sculpt_project.cc b/source/blender/editors/sculpt_paint/sculpt_project.cc index 78e3f4e11bd..f1ea6820c29 100644 --- a/source/blender/editors/sculpt_paint/sculpt_project.cc +++ b/source/blender/editors/sculpt_paint/sculpt_project.cc @@ -200,7 +200,7 @@ static void gesture_apply_for_symmetry_pass(bContext &C, gesture::GestureData &g break; } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } static void gesture_end(bContext &C, gesture::GestureData &gesture_data) diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.cc b/source/blender/editors/sculpt_paint/sculpt_transform.cc index 204b1fea1cf..a8fbe41199f 100644 --- a/source/blender/editors/sculpt_paint/sculpt_transform.cc +++ b/source/blender/editors/sculpt_paint/sculpt_transform.cc @@ -334,7 +334,7 @@ static void sculpt_transform_all_vertices(const Depsgraph &depsgraph, const Scul } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } BLI_NOINLINE static void calc_transform_translations(const float4x4 &elastic_transform_mat, @@ -532,7 +532,7 @@ static void transform_radius_elastic(const Depsgraph &depsgraph, } } pbvh.tag_positions_changed(node_mask); - bke::pbvh::flush_bounds_to_parents(pbvh); + pbvh.flush_bounds_to_parents(); } void update_modal_transform(bContext *C, Object &ob) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index b484690da7f..71e43039d5f 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -898,7 +898,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) * We need to manually clear that cache. */ mesh.runtime->corner_normals_cache.tag_dirty(); } - bke::pbvh::update_bounds(*depsgraph, object, pbvh); + pbvh.update_bounds(*depsgraph, object); bke::pbvh::store_bounds_orig(pbvh); break; } @@ -939,7 +939,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) } BKE_pbvh_sync_visibility_from_verts(object); - bke::pbvh::update_visibility(object, pbvh); + pbvh.update_visibility(object); if (BKE_sculpt_multires_active(scene, &object)) { multires_mark_as_modified(depsgraph, &object, MULTIRES_HIDDEN_MODIFIED); } @@ -982,7 +982,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) } hide::sync_all_from_faces(object); - bke::pbvh::update_visibility(object, pbvh); + pbvh.update_visibility(object); break; } case Type::Mask: {