From d5e591b3dc8c4c49e1fb97dc4eb9aee2eb30d15b Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 22 Aug 2024 23:37:10 +0200 Subject: [PATCH] Refactor: Sculpt: Add helper function to access all BVH nodes Previously we often passed an empty `FunctionRef` to the generic `search_gather` function. The plan is to refactor `search_gather` to return an `IndexMask` along with storing leaf nodes in a separate array. Splitting access to all leaf nodes to a separate function simplifies this process and makes code more expressive too. Part of #118145. Pull Request: https://projects.blender.org/blender/blender/pulls/126667 --- source/blender/blenkernel/BKE_pbvh_api.hh | 4 ++++ source/blender/blenkernel/intern/paint.cc | 4 +--- source/blender/blenkernel/intern/pbvh.cc | 13 +++++++++++++ .../blender/editors/sculpt_paint/paint_hide.cc | 8 ++++---- .../blender/editors/sculpt_paint/paint_mask.cc | 2 +- .../editors/sculpt_paint/paint_vertex.cc | 2 +- .../sculpt_paint/paint_vertex_color_ops.cc | 2 +- source/blender/editors/sculpt_paint/sculpt.cc | 12 ++++++------ .../editors/sculpt_paint/sculpt_cloth.cc | 12 ++++++------ .../editors/sculpt_paint/sculpt_detail.cc | 2 +- .../editors/sculpt_paint/sculpt_expand.cc | 13 ++++++------- .../editors/sculpt_paint/sculpt_face_set.cc | 12 ++++++------ .../editors/sculpt_paint/sculpt_filter_mask.cc | 2 +- .../editors/sculpt_paint/sculpt_mask_init.cc | 2 +- .../blender/editors/sculpt_paint/sculpt_ops.cc | 6 +++--- .../blender/editors/sculpt_paint/sculpt_pose.cc | 2 +- .../editors/sculpt_paint/sculpt_smooth.cc | 2 +- .../blender/editors/sculpt_paint/sculpt_undo.cc | 17 ++++++++--------- 18 files changed, 65 insertions(+), 52 deletions(-) diff --git a/source/blender/blenkernel/BKE_pbvh_api.hh b/source/blender/blenkernel/BKE_pbvh_api.hh index 0785f4595b5..1a4b5d8305f 100644 --- a/source/blender/blenkernel/BKE_pbvh_api.hh +++ b/source/blender/blenkernel/BKE_pbvh_api.hh @@ -539,6 +539,10 @@ void BKE_pbvh_ensure_node_face_corners(blender::bke::pbvh::Tree &pbvh, int BKE_pbvh_debug_draw_gen_get(blender::bke::pbvh::Node &node); namespace blender::bke::pbvh { + +/** Return pointers to all the leaf nodes in the BVH tree. */ +Vector all_leaf_nodes(Tree &pbvh); + Vector search_gather(Tree &pbvh, FunctionRef scb, PBVHNodeFlags leaf_flag = PBVH_Leaf); diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 847de3ba123..648d8d82eb0 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -2117,9 +2117,7 @@ void BKE_sculpt_update_object_before_eval(Object *ob_eval) BKE_sculptsession_free_vwpaint_data(ob_eval->sculpt); } else if (ss->pbvh) { - Vector nodes = blender::bke::pbvh::search_gather(*ss->pbvh, {}); - - for (blender::bke::pbvh::Node *node : nodes) { + for (blender::bke::pbvh::Node *node : blender::bke::pbvh::all_leaf_nodes(*ss->pbvh)) { BKE_pbvh_node_mark_update(*node); } } diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 56d573818af..d27ad218bbe 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -2973,6 +2973,19 @@ void BKE_pbvh_sync_visibility_from_verts(Object &object) } namespace blender::bke::pbvh { + +Vector all_leaf_nodes(Tree &pbvh) +{ + Vector leaf_nodes; + leaf_nodes.reserve(pbvh.nodes_.size()); + for (Node &node : pbvh.nodes_) { + if (node.flag_ & PBVH_Leaf) { + leaf_nodes.append(&node); + } + } + return leaf_nodes; +} + Vector search_gather(Tree &pbvh, const FunctionRef scb, PBVHNodeFlags leaf_flag) diff --git a/source/blender/editors/sculpt_paint/paint_hide.cc b/source/blender/editors/sculpt_paint/paint_hide.cc index d4c7d21cb86..222d34865cb 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.cc +++ b/source/blender/editors/sculpt_paint/paint_hide.cc @@ -521,7 +521,7 @@ static int hide_show_all_exec(bContext *C, wmOperator *op) break; } - Vector nodes = bke::pbvh::search_gather(*pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*pbvh); switch (pbvh->type()) { case bke::pbvh::Type::Mesh: @@ -639,7 +639,7 @@ static int hide_show_masked_exec(bContext *C, wmOperator *op) break; } - Vector nodes = bke::pbvh::search_gather(*pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*pbvh); switch (pbvh->type()) { case bke::pbvh::Type::Mesh: @@ -792,7 +792,7 @@ static int visibility_invert_exec(bContext *C, wmOperator *op) bke::pbvh::Tree *pbvh = BKE_sculpt_object_pbvh_ensure(&depsgraph, &object); BLI_assert(BKE_object_sculpt_pbvh_get(&object) == pbvh); - Vector nodes = bke::pbvh::search_gather(*pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*pbvh); undo::push_begin(object, op); switch (pbvh->type()) { case bke::pbvh::Type::Mesh: @@ -1128,7 +1128,7 @@ static int visibility_filter_exec(bContext *C, wmOperator *op) const VisAction mode = VisAction(RNA_enum_get(op->ptr, "action")); - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); int num_verts = SCULPT_vertex_count_get(object); diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc b/source/blender/editors/sculpt_paint/paint_mask.cc index 344046fe8db..9138203dba6 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_mask.cc @@ -572,7 +572,7 @@ static void fill_mask( Main &bmain, const Scene &scene, Depsgraph &depsgraph, Object &object, const float value) { bke::pbvh::Tree &pbvh = *object.sculpt->pbvh; - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); switch (pbvh.type()) { case bke::pbvh::Type::Mesh: fill_mask_mesh(depsgraph, object, value, nodes); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index f708d2259e6..fdb42a3c27a 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -2303,7 +2303,7 @@ static int vertex_color_set_exec(bContext *C, wmOperator *op) BKE_sculpt_update_object_for_edit(CTX_data_ensure_evaluated_depsgraph(C), &obact, true); undo::push_begin(obact, op); - Vector nodes = bke::pbvh::search_gather(*obact.sculpt->pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*obact.sculpt->pbvh); const Mesh &mesh = *static_cast(obact.data); /* The sculpt undo system needs bke::pbvh::Tree node corner indices for corner domain diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc index bab8307defd..4225df03fca 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.cc @@ -322,7 +322,7 @@ static void transform_active_color(bContext *C, * attributes. */ BKE_pbvh_ensure_node_face_corners(pbvh, mesh.corner_tris()); - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); undo::push_nodes(depsgraph, obact, nodes, undo::Type::Color); transform_active_color_data(*BKE_mesh_from_object(&obact), transform_fn); diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 586191ef728..d3e947c69d5 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -1214,7 +1214,7 @@ namespace undo { static void restore_mask_from_undo_step(Object &object) { SculptSession &ss = *object.sculpt; - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); switch (ss.pbvh->type()) { case bke::pbvh::Type::Mesh: { @@ -1279,7 +1279,7 @@ static void restore_mask_from_undo_step(Object &object) static void restore_color_from_undo_step(Object &object) { SculptSession &ss = *object.sculpt; - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); BLI_assert(ss.pbvh->type() == bke::pbvh::Type::Mesh); Mesh &mesh = *static_cast(object.data); @@ -1309,7 +1309,7 @@ static void restore_color_from_undo_step(Object &object) static void restore_face_set_from_undo_step(Object &object) { SculptSession &ss = *object.sculpt; - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); switch (ss.pbvh->type()) { case bke::pbvh::Type::Mesh: @@ -1336,7 +1336,7 @@ static void restore_face_set_from_undo_step(Object &object) void restore_position_from_undo_step(const Depsgraph &depsgraph, Object &object) { SculptSession &ss = *object.sculpt; - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); switch (ss.pbvh->type()) { case bke::pbvh::Type::Mesh: { @@ -3404,7 +3404,7 @@ static void do_brush_action(const Depsgraph &depsgraph, if (SCULPT_tool_needs_all_pbvh_nodes(brush)) { /* These brushes need to update all nodes as they are not constrained by the brush radius */ - nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); } else if (brush.sculpt_tool == SCULPT_TOOL_CLOTH) { nodes = cloth::brush_affected_nodes_gather(ss, brush); @@ -6282,7 +6282,7 @@ static SculptTopologyIslandCache calc_topology_islands_bmesh(const Object &objec BM_mesh_elem_index_ensure(&bm, BM_VERT); bke::pbvh::Tree &pbvh = *object.sculpt->pbvh; - const Vector nodes = bke::pbvh::search_gather(pbvh, {}); + const Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); AtomicDisjointSet disjoint_set(bm.totvert); threading::parallel_for(nodes.index_range(), 1024, [&](const IndexRange range) { for (bke::pbvh::Node *node : nodes.as_span().slice(range)) { diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index fc6120ba488..19ad8b4c256 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -188,7 +188,7 @@ Vector brush_affected_nodes_gather(SculptSession &ss, const B }); } case BRUSH_CLOTH_SIMULATION_AREA_GLOBAL: - return bke::pbvh::search_gather(*ss.pbvh, {}); + return bke::pbvh::all_leaf_nodes(*ss.pbvh); case BRUSH_CLOTH_SIMULATION_AREA_DYNAMIC: { const float radius_squared = math::square(ss.cache->radius * (1.0 + brush.cloth_sim_limit)); return bke::pbvh::search_gather(*ss.pbvh, [&](bke::pbvh::Node &node) { @@ -1213,8 +1213,8 @@ static void calc_constraint_factors(const Depsgraph &depsgraph, { const SculptSession &ss = *object.sculpt; const bke::pbvh::Tree &pbvh = *ss.pbvh; - const Vector nodes = bke::pbvh::search_gather( - const_cast(pbvh), {}); + const Vector nodes = bke::pbvh::all_leaf_nodes( + const_cast(pbvh)); const auto_mask::Cache *automasking = auto_mask::active_cache_get(ss); @@ -1607,7 +1607,7 @@ static void cloth_brush_apply_brush_foces(const Depsgraph &depsgraph, * them. */ static void cloth_sim_initialize_default_node_state(SculptSession &ss, SimulationData &cloth_sim) { - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); cloth_sim.node_state = Array(nodes.size()); for (const int i : nodes.index_range()) { @@ -1628,7 +1628,7 @@ static void copy_positions_to_array(const Depsgraph &depsgraph, break; case bke::pbvh::Type::Grids: { SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - Vector all_nodes = bke::pbvh::search_gather(pbvh, {}); + Vector all_nodes = bke::pbvh::all_leaf_nodes(pbvh); threading::parallel_for(all_nodes.index_range(), 8, [&](const IndexRange range) { Vector node_positions; for (const int i : range) { @@ -1658,7 +1658,7 @@ static void copy_normals_to_array(const Depsgraph &depsgraph, case bke::pbvh::Type::Grids: { SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - Vector all_nodes = bke::pbvh::search_gather(pbvh, {}); + Vector all_nodes = bke::pbvh::all_leaf_nodes(pbvh); threading::parallel_for(all_nodes.index_range(), 8, [&](const IndexRange range) { Vector node_normals; for (const int i : range) { diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.cc b/source/blender/editors/sculpt_paint/sculpt_detail.cc index 6557c681e14..65b6d5a4116 100644 --- a/source/blender/editors/sculpt_paint/sculpt_detail.cc +++ b/source/blender/editors/sculpt_paint/sculpt_detail.cc @@ -108,7 +108,7 @@ static int sculpt_detail_flood_fill_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); if (nodes.is_empty()) { return OPERATOR_CANCELLED; diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc b/source/blender/editors/sculpt_paint/sculpt_expand.cc index b1aa329b993..0ea0cfeced4 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.cc +++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc @@ -1427,8 +1427,7 @@ static void restore_face_set_data(Object &object, Cache &expand_cache) face_sets.span.copy_from(expand_cache.original_face_sets); face_sets.finish(); - Vector nodes = bke::pbvh::search_gather(*object.sculpt->pbvh, {}); - for (bke::pbvh::Node *node : nodes) { + for (bke::pbvh::Node *node : bke::pbvh::all_leaf_nodes(*object.sculpt->pbvh)) { BKE_pbvh_node_mark_update_face_sets(*node); } } @@ -1437,7 +1436,7 @@ static void restore_color_data(Object &ob, Cache &expand_cache) { SculptSession &ss = *ob.sculpt; Mesh &mesh = *static_cast(ob.data); - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); const OffsetIndices faces = mesh.faces(); const Span corner_verts = mesh.corner_verts(); @@ -1498,7 +1497,7 @@ static void write_mask_data(Object &object, const Span mask) } } - for (bke::pbvh::Node *node : bke::pbvh::search_gather(*ss.pbvh, {})) { + for (bke::pbvh::Node *node : bke::pbvh::all_leaf_nodes(*ss.pbvh)) { BKE_pbvh_node_mark_update_mask(*node); } } @@ -2018,7 +2017,7 @@ static void finish(bContext *C) undo::push_end(ob); /* Tag all nodes to redraw to avoid artifacts after the fast partial updates. */ - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); for (bke::pbvh::Node *node : nodes) { BKE_pbvh_node_mark_update_mask(*node); } @@ -2485,7 +2484,7 @@ static void cache_initial_config_set(bContext *C, wmOperator *op, Cache &expand_ static void undo_push(const Depsgraph &depsgraph, Object &ob, Cache &expand_cache) { SculptSession &ss = *ob.sculpt; - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); switch (expand_cache.target) { case TargetType::Mask: @@ -2619,7 +2618,7 @@ static int sculpt_expand_invoke(bContext *C, wmOperator *op, const wmEvent *even set_initial_components_for_mouse(C, ob, *ss.expand_cache, mouse); /* Cache bke::pbvh::Tree nodes. */ - ss.expand_cache->nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + ss.expand_cache->nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); /* Store initial state. */ original_state_store(ob, *ss.expand_cache); diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index ba29d993ca3..c0b0c444cb7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -394,7 +394,7 @@ static int create_op_exec(bContext *C, wmOperator *op) const int next_face_set = find_next_available_id(object); - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); switch (mode) { case CreateMode::Masked: { const OffsetIndices faces = mesh.faces(); @@ -644,7 +644,7 @@ static int init_op_exec(bContext *C, wmOperator *op) } bke::pbvh::Tree &pbvh = *ob.sculpt->pbvh; - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); if (nodes.is_empty()) { return OPERATOR_CANCELLED; @@ -906,7 +906,7 @@ static int change_visibility_exec(bContext *C, wmOperator *op) undo::push_begin(object, op); bke::pbvh::Tree &pbvh = *object.sculpt->pbvh; - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); const bke::AttributeAccessor attributes = mesh->attributes(); const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); @@ -1072,7 +1072,7 @@ static int randomize_colors_exec(bContext *C, wmOperator * /*op*/) mesh->face_sets_color_seed += 1; - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); for (bke::pbvh::Node *node : nodes) { BKE_pbvh_node_mark_redraw(*node); } @@ -1123,7 +1123,7 @@ static void edit_grow_shrink(const Depsgraph &depsgraph, undo::push_begin(object, op); - const Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + const Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); face_sets_update( depsgraph, object, nodes, [&](const Span indices, MutableSpan face_sets) { for (const int i : indices.index_range()) { @@ -1379,7 +1379,7 @@ static void edit_modify_coordinates( const Sculpt &sd = *CTX_data_tool_settings(C)->sculpt; SculptSession &ss = *ob.sculpt; bke::pbvh::Tree &pbvh = *ss.pbvh; - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); const float strength = RNA_float_get(op->ptr, "strength"); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc index 4b8e178d201..81d316be293 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc @@ -659,7 +659,7 @@ static int sculpt_mask_filter_exec(bContext *C, wmOperator *op) SculptSession &ss = *ob.sculpt; bke::pbvh::Tree &pbvh = *ob.sculpt->pbvh; - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); undo::push_begin(ob, op); int iterations = RNA_int_get(op->ptr, "iterations"); diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc index 81c987b63d0..ab7a75f3ad7 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc +++ b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc @@ -118,7 +118,7 @@ static int sculpt_mask_init_exec(bContext *C, wmOperator *op) BKE_sculpt_update_object_for_edit(&depsgraph, &ob, false); bke::pbvh::Tree &pbvh = *ob.sculpt->pbvh; - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); if (nodes.is_empty()) { return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.cc b/source/blender/editors/sculpt_paint/sculpt_ops.cc index e201fd80e61..1f9dca5928e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/sculpt_ops.cc @@ -782,7 +782,7 @@ static void sculpt_mask_by_color_contiguous_mesh(const Depsgraph &depsgraph, return len <= threshold; }); - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); update_mask_mesh( depsgraph, object, nodes, [&](MutableSpan node_mask, const Span verts) { @@ -807,7 +807,7 @@ static void sculpt_mask_by_color_full_mesh(const Depsgraph &depsgraph, mesh.active_color_attribute, bke::AttrDomain::Point, {}); const float4 active_color = float4(colors[vert]); - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); update_mask_mesh( depsgraph, object, nodes, [&](MutableSpan node_mask, const Span verts) { @@ -1084,7 +1084,7 @@ static int sculpt_bake_cavity_exec(bContext *C, wmOperator *op) CavityBakeMixMode mode = CavityBakeMixMode(RNA_enum_get(op->ptr, "mix_mode")); float factor = RNA_float_get(op->ptr, "mix_factor"); - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); /* Set up automasking settings. */ Sculpt sd2 = sd; diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.cc b/source/blender/editors/sculpt_paint/sculpt_pose.cc index e3904c4ff11..5777ba37e22 100644 --- a/source/blender/editors/sculpt_paint/sculpt_pose.cc +++ b/source/blender/editors/sculpt_paint/sculpt_pose.cc @@ -488,7 +488,7 @@ static void grow_pose_factor(const Depsgraph &depsgraph, bke::pbvh::Tree &pbvh = *ob.sculpt->pbvh; const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(ob); - Vector nodes = bke::pbvh::search_gather(pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(pbvh); const Span fake_neighbors = ss.fake_neighbors.fake_neighbor_index; bool grow_next_iteration = true; diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.cc b/source/blender/editors/sculpt_paint/sculpt_smooth.cc index e4a3f55f27c..ee7a94220ca 100644 --- a/source/blender/editors/sculpt_paint/sculpt_smooth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_smooth.cc @@ -737,7 +737,7 @@ void blur_geometry_data_array(const Object &object, Vector new_factors; }; const SculptSession &ss = *object.sculpt; - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); threading::EnumerableThreadSpecific all_tls; switch (ss.pbvh->type()) { diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index af869cbe4e7..6f5281f714a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -604,8 +604,7 @@ static void bmesh_restore_generic(StepData &step_data, Object &object, SculptSes } if (step_data.type == Type::Mask) { - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); - for (bke::pbvh::Node *node : nodes) { + for (bke::pbvh::Node *node : bke::pbvh::all_leaf_nodes(*ss.pbvh)) { BKE_pbvh_node_mark_redraw(*node); } } @@ -856,7 +855,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) break; } case Type::Position: { - const Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + const Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); BKE_sculpt_update_object_for_edit(depsgraph, &object, false); if (!topology_matches(step_data, object)) { @@ -903,7 +902,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) break; } case Type::HideVert: { - const Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + const Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); BKE_sculpt_update_object_for_edit(depsgraph, &object, false); if (!topology_matches(step_data, object)) { @@ -942,7 +941,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) break; } case Type::HideFace: { - const Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + const Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); BKE_sculpt_update_object_for_edit(depsgraph, &object, false); if (!topology_matches(step_data, object)) { @@ -984,7 +983,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) break; } case Type::Mask: { - const Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + const Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); BKE_sculpt_update_object_for_edit(depsgraph, &object, false); if (!topology_matches(step_data, object)) { @@ -1018,7 +1017,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) break; } case Type::FaceSet: { - const Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + const Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); BKE_sculpt_update_object_for_edit(depsgraph, &object, false); if (!topology_matches(step_data, object)) { @@ -1056,7 +1055,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) break; } case Type::Color: { - const Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + const Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); BKE_sculpt_update_object_for_edit(depsgraph, &object, false); if (!topology_matches(step_data, object)) { @@ -2030,7 +2029,7 @@ static void push_all_grids(const Depsgraph &depsgraph, Object *object) return; } - Vector nodes = bke::pbvh::search_gather(*ss.pbvh, {}); + Vector nodes = bke::pbvh::all_leaf_nodes(*ss.pbvh); push_nodes(depsgraph, *object, nodes, Type::Position); }