From 8747e9facdb7e095ee4cb68c34c1bd974783eb34 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 5 Sep 2024 11:06:50 -0400 Subject: [PATCH] Cleanup: Sculpt: Add geometry index accessor functions to node structs Add `.faces()`, `.verts()`,`.all_verts()`, and `.grids()` functions to nodes. Don't change BMesh data access yet. More complex const correctness makes that situation more difficult. --- source/blender/blenkernel/BKE_pbvh_api.hh | 37 ++++++++++-- source/blender/blenkernel/intern/pbvh.cc | 51 +++++----------- .../blender/blenkernel/intern/pbvh_pixels.cc | 2 +- source/blender/draw/intern/draw_pbvh.cc | 58 +++++++------------ .../editors/sculpt_paint/brushes/clay.cc | 4 +- .../sculpt_paint/brushes/clay_strips.cc | 4 +- .../sculpt_paint/brushes/clay_thumb.cc | 4 +- .../editors/sculpt_paint/brushes/crease.cc | 4 +- .../editors/sculpt_paint/brushes/draw.cc | 4 +- .../sculpt_paint/brushes/draw_face_sets.cc | 4 +- .../sculpt_paint/brushes/draw_sharp.cc | 4 +- .../brushes/draw_vector_displacement.cc | 4 +- .../sculpt_paint/brushes/elastic_deform.cc | 4 +- .../sculpt_paint/brushes/enhance_details.cc | 8 +-- .../editors/sculpt_paint/brushes/fill.cc | 4 +- .../editors/sculpt_paint/brushes/flatten.cc | 4 +- .../editors/sculpt_paint/brushes/grab.cc | 4 +- .../editors/sculpt_paint/brushes/inflate.cc | 4 +- .../editors/sculpt_paint/brushes/layer.cc | 4 +- .../editors/sculpt_paint/brushes/mask.cc | 4 +- .../sculpt_paint/brushes/multiplane_scrape.cc | 8 +-- .../brushes/multires_displacement_eraser.cc | 2 +- .../brushes/multires_displacement_smear.cc | 4 +- .../editors/sculpt_paint/brushes/pinch.cc | 4 +- .../editors/sculpt_paint/brushes/relax.cc | 24 ++++---- .../editors/sculpt_paint/brushes/rotate.cc | 4 +- .../editors/sculpt_paint/brushes/scrape.cc | 4 +- .../editors/sculpt_paint/brushes/smooth.cc | 6 +- .../sculpt_paint/brushes/smooth_mask.cc | 6 +- .../sculpt_paint/brushes/snake_hook.cc | 4 +- .../sculpt_paint/brushes/surface_smooth.cc | 12 ++-- .../editors/sculpt_paint/brushes/thumb.cc | 4 +- .../sculpt_paint/brushes/topology_slide.cc | 4 +- .../editors/sculpt_paint/paint_hide.cc | 20 +++---- .../editors/sculpt_paint/paint_mask.cc | 10 ++-- .../editors/sculpt_paint/paint_vertex.cc | 10 ++-- .../editors/sculpt_paint/paint_weight.cc | 8 +-- source/blender/editors/sculpt_paint/sculpt.cc | 31 +++++----- .../editors/sculpt_paint/sculpt_boundary.cc | 24 ++++---- .../editors/sculpt_paint/sculpt_cloth.cc | 22 +++---- .../editors/sculpt_paint/sculpt_expand.cc | 6 +- .../editors/sculpt_paint/sculpt_face_set.cc | 10 ++-- .../sculpt_paint/sculpt_filter_color.cc | 6 +- .../sculpt_paint/sculpt_filter_mask.cc | 24 ++++---- .../sculpt_paint/sculpt_filter_mesh.cc | 50 ++++++++-------- .../editors/sculpt_paint/sculpt_hide.cc | 2 +- .../editors/sculpt_paint/sculpt_mask_init.cc | 2 +- .../editors/sculpt_paint/sculpt_ops.cc | 4 +- .../sculpt_paint/sculpt_paint_color.cc | 10 ++-- .../editors/sculpt_paint/sculpt_pose.cc | 6 +- .../editors/sculpt_paint/sculpt_project.cc | 4 +- .../editors/sculpt_paint/sculpt_smooth.cc | 2 +- .../editors/sculpt_paint/sculpt_transform.cc | 16 ++--- .../editors/sculpt_paint/sculpt_undo.cc | 34 +++++------ 54 files changed, 295 insertions(+), 308 deletions(-) diff --git a/source/blender/blenkernel/BKE_pbvh_api.hh b/source/blender/blenkernel/BKE_pbvh_api.hh index 983d27d65ea..73e827e9bef 100644 --- a/source/blender/blenkernel/BKE_pbvh_api.hh +++ b/source/blender/blenkernel/BKE_pbvh_api.hh @@ -140,11 +140,24 @@ struct MeshNode : public Node { LocalVertMap vert_indices_; /** The number of vertices in #vert_indices not shared with (owned by) another node. */ int unique_verts_num_ = 0; + + /** Return the faces contained by the node. */ + Span faces() const; + /** Return the "unique" vertices owned by the node, excluding vertices owned by other nodes. */ + Span verts() const; + /** + * Return all vertices used by faces in this node. The same as #verts(), with the shared + * vertices added at the end of the array. + */ + Span all_verts() const; }; struct GridsNode : public Node { /** Multires grid indices for this node. Refers to a subset of Tree::prim_indices_. */ Span prim_indices_; + + /** Return grid indices contained by the node. */ + Span grids() const; }; struct BMeshNode : public Node { @@ -384,12 +397,6 @@ namespace blender::bke::pbvh { void remove_node_draw_tags(bke::pbvh::Tree &pbvh, const IndexMask &node_mask); -Span node_grid_indices(const GridsNode &node); - -Span node_faces(const MeshNode &node); -Span node_verts(const MeshNode &node); -Span node_unique_verts(const MeshNode &node); - /** * Gather the indices of all base mesh faces in the node. * For convenience, pass a reference to the data in the result. @@ -535,4 +542,22 @@ void update_node_bounds_mesh(Span positions, MeshNode &node); void update_node_bounds_grids(const CCGKey &key, Span grids, GridsNode &node); void update_node_bounds_bmesh(BMeshNode &node); +inline Span MeshNode::faces() const +{ + return this->face_indices_; +} +inline Span MeshNode::verts() const +{ + return this->vert_indices_.as_span().slice(0, this->unique_verts_num_); +} +inline Span MeshNode::all_verts() const +{ + return this->vert_indices_; +} + +inline Span GridsNode::grids() const +{ + return this->prim_indices_; +} + } // namespace blender::bke::pbvh diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 28e10e47ad4..82943a3b5e4 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -436,7 +436,7 @@ std::unique_ptr build_mesh(const Mesh &mesh) if (!hide_vert.is_empty()) { threading::parallel_for(nodes.index_range(), 8, [&](const IndexRange range) { for (const int i : range) { - const Span verts = node_verts(nodes[i]); + const Span verts = nodes[i].all_verts(); if (std::all_of(verts.begin(), verts.end(), [&](const int i) { return hide_vert[i]; })) { nodes[i].flag_ |= PBVH_FullyHidden; } @@ -620,7 +620,7 @@ std::unique_ptr build_grids(const Mesh &base_mesh, const SubdivCCG &subdiv if (!grid_hidden.is_empty()) { threading::parallel_for(nodes.index_range(), 8, [&](const IndexRange range) { for (const int i : range) { - const Span grids = node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); if (std::all_of(grids.begin(), grids.end(), [&](const int i) { return !bits::any_bit_unset(grid_hidden[i]); })) @@ -1022,7 +1022,7 @@ static void calc_node_face_normals(const Span positions, MutableSpan face_normals) { nodes_to_update.foreach_index(GrainSize(1), [&](const int i) { - normals_calc_faces(positions, faces, corner_verts, node_faces(nodes[i]), face_normals); + normals_calc_faces(positions, faces, corner_verts, nodes[i].faces(), face_normals); }); } @@ -1057,8 +1057,7 @@ static void calc_node_vert_normals(const GroupedSpan vert_to_face_map, MutableSpan vert_normals) { nodes_to_update.foreach_index(GrainSize(1), [&](const int i) { - normals_calc_verts_simple( - vert_to_face_map, face_normals, node_unique_verts(nodes[i]), vert_normals); + normals_calc_verts_simple(vert_to_face_map, face_normals, nodes[i].verts(), vert_normals); }); } @@ -1190,7 +1189,7 @@ void update_normals_from_eval(Object &object_eval, Tree &pbvh) void update_node_bounds_mesh(const Span positions, MeshNode &node) { Bounds bounds = negative_bounds(); - for (const int vert : node_verts(node)) { + for (const int vert : node.all_verts()) { math::min_max(positions[vert], bounds.min, bounds.max); } node.bounds_ = bounds; @@ -1199,7 +1198,7 @@ void update_node_bounds_mesh(const Span positions, MeshNode &node) void update_node_bounds_grids(const CCGKey &key, const Span grids, GridsNode &node) { Bounds bounds = negative_bounds(); - for (const int grid : node_grid_indices(node)) { + for (const int grid : node.grids()) { for (const int i : IndexRange(key.grid_area)) { math::min_max(CCG_elem_offset_co(key, grids[grid], i), bounds.min, bounds.max); } @@ -1334,7 +1333,7 @@ void store_bounds_orig(Tree &pbvh) void node_update_mask_mesh(const Span mask, MeshNode &node) { - const Span verts = node_verts(node); + const Span verts = node.all_verts(); const bool fully_masked = std::all_of( verts.begin(), verts.end(), [&](const int vert) { return mask[vert] == 1.0f; }); const bool fully_unmasked = std::all_of( @@ -1368,7 +1367,7 @@ void node_update_mask_grids(const CCGKey &key, const Span grids, Grid BLI_assert(key.has_mask); bool fully_masked = true; bool fully_unmasked = true; - for (const int grid : node_grid_indices(node)) { + for (const int grid : node.grids()) { CCGElem *elem = grids[grid]; for (const int i : IndexRange(key.grid_area)) { const float mask = CCG_elem_offset_mask(key, elem, i); @@ -1465,7 +1464,7 @@ void update_mask(const Object &object, Tree &pbvh) void node_update_visibility_mesh(const Span hide_vert, MeshNode &node) { BLI_assert(!hide_vert.is_empty()); - const Span verts = node_verts(node); + const Span verts = node.all_verts(); const bool fully_hidden = std::all_of( verts.begin(), verts.end(), [&](const int vert) { return hide_vert[vert]; }); SET_FLAG_FROM_TEST(node.flag_, fully_hidden, PBVH_FullyHidden); @@ -1633,7 +1632,7 @@ IndexMask nodes_to_face_selection_grids(const SubdivCCG &subdiv_ccg, * overhead regardless of selection size, but that is small. */ Array faces_to_update(subdiv_ccg.faces.size(), false); nodes_mask.foreach_index(GrainSize(1), [&](const int i) { - for (const int grid : node_grid_indices(nodes[i])) { + for (const int grid : nodes[i].grids()) { faces_to_update[grid_to_face_map[grid]] = true; } }); @@ -1807,16 +1806,6 @@ void remove_node_draw_tags(bke::pbvh::Tree &pbvh, const IndexMask &node_mask) } } -Span node_verts(const MeshNode &node) -{ - return node.vert_indices_; -} - -Span node_unique_verts(const MeshNode &node) -{ - return node.vert_indices_.as_span().take_front(node.unique_verts_num_); -} - Span node_face_indices_calc_grids(const SubdivCCG &subdiv_ccg, const GridsNode &node, Vector &faces) @@ -1824,7 +1813,7 @@ Span node_face_indices_calc_grids(const SubdivCCG &subdiv_ccg, faces.clear(); const Span grid_to_face_map = subdiv_ccg.grid_to_face_map; int prev_face = -1; - for (const int grid : node_grid_indices(node)) { + for (const int grid : node.grids()) { const int face = grid_to_face_map[grid]; if (face != prev_face) { faces.append(face); @@ -1834,16 +1823,6 @@ Span node_face_indices_calc_grids(const SubdivCCG &subdiv_ccg, return faces.as_span(); } -Span node_faces(const MeshNode &node) -{ - return node.face_indices_; -} - -Span node_grid_indices(const GridsNode &node) -{ - return node.prim_indices_; -} - } // namespace blender::bke::pbvh namespace blender::bke::pbvh { @@ -2071,7 +2050,7 @@ static bool pbvh_faces_node_raycast(const MeshNode &node, int *r_active_face_index, float *r_face_normal) { - const Span face_indices = node_faces(node); + const Span face_indices = node.faces(); bool hit = false; if (node_positions.is_empty()) { @@ -2192,7 +2171,7 @@ static bool pbvh_grids_node_raycast(const SubdivCCG &subdiv_ccg, float *r_face_normal) { const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = node_grid_indices(node); + const Span grids = node.grids(); const int grid_size = key.grid_size; bool hit = false; const BitGroupVector<> &grid_hidden = subdiv_ccg.grid_hidden; @@ -2473,7 +2452,7 @@ static bool pbvh_faces_node_nearest_to_ray(const MeshNode &node, float *depth, float *dist_sq) { - const Span face_indices = node_faces(node); + const Span face_indices = node.faces(); bool hit = false; if (node_positions.is_empty()) { @@ -2528,7 +2507,7 @@ static bool pbvh_grids_node_nearest_to_ray(const SubdivCCG &subdiv_ccg, float *dist_sq) { const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = node_grid_indices(node); + const Span grids = node.grids(); const int grid_size = key.grid_size; const BitGroupVector<> &grid_hidden = subdiv_ccg.grid_hidden; const Span elems = subdiv_ccg.grids; diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index dfa3234be42..e253daaa0bf 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -163,7 +163,7 @@ static void do_encode_pixels(const uv_islands::MeshData &mesh_data, tile_data.tile_number = image_tile.get_tile_number(); float2 tile_offset = float2(image_tile.get_tile_offset()); - for (const int face : node_faces(node)) { + for (const int face : node.faces()) { for (const int tri : bke::mesh::face_triangles_range(mesh_data.faces, face)) { for (const UVPrimitiveLookup::Entry &entry : uv_prim_lookup.lookup[tri]) { uv_islands::UVBorder uv_border = entry.uv_primitive->extract_border(); diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index d939532a5e9..2de04621778 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -909,8 +909,7 @@ static void fill_vbos_grids(const Object &object, switch (*request_type) { case CustomRequest::Position: { node_mask.foreach_index(GrainSize(1), [&](const int i) { - fill_vbo_position_grids( - key, grids, use_flat_layout[i], bke::pbvh::node_grid_indices(nodes[i]), *vbos[i]); + fill_vbo_position_grids(key, grids, use_flat_layout[i], nodes[i].grids(), *vbos[i]); }); break; } @@ -925,7 +924,7 @@ static void fill_vbos_grids(const Object &object, grid_to_face_map, sharp_faces, use_flat_layout[i], - bke::pbvh::node_grid_indices(nodes[i]), + nodes[i].grids(), *vbos[i]); }); @@ -933,8 +932,7 @@ static void fill_vbos_grids(const Object &object, } case CustomRequest::Mask: { node_mask.foreach_index(GrainSize(1), [&](const int i) { - fill_vbo_mask_grids( - key, grids, use_flat_layout[i], bke::pbvh::node_grid_indices(nodes[i]), *vbos[i]); + fill_vbo_mask_grids(key, grids, use_flat_layout[i], nodes[i].grids(), *vbos[i]); }); break; } @@ -954,7 +952,7 @@ static void fill_vbos_grids(const Object &object, face_set_default, face_set_seed, use_flat_layout[i], - bke::pbvh::node_grid_indices(nodes[i]), + nodes[i].grids(), *vbos[i]); }); } @@ -1007,7 +1005,7 @@ static void fill_vbos_mesh(const Object &object, corner_tris, hide_poly, vert_positions, - bke::pbvh::node_faces(nodes[i]), + nodes[i].faces(), *vbos[i]); }); break; @@ -1025,7 +1023,7 @@ static void fill_vbos_mesh(const Object &object, hide_poly, vert_normals, face_normals, - bke::pbvh::node_faces(nodes[i]), + nodes[i].faces(), *vbos[i]); }); break; @@ -1035,13 +1033,8 @@ static void fill_vbos_mesh(const Object &object, bke::AttrDomain::Point); if (!mask.is_empty()) { node_mask.foreach_index(GrainSize(1), [&](const int i) { - fill_vbo_mask_mesh(faces, - corner_verts, - corner_tris, - hide_poly, - mask, - bke::pbvh::node_faces(nodes[i]), - *vbos[i]); + fill_vbo_mask_mesh( + faces, corner_verts, corner_tris, hide_poly, mask, nodes[i].faces(), *vbos[i]); }); } else { @@ -1062,7 +1055,7 @@ static void fill_vbos_mesh(const Object &object, face_sets, face_set_default, face_set_seed, - bke::pbvh::node_faces(nodes[i]), + nodes[i].faces(), *vbos[i]); }); } @@ -1087,7 +1080,7 @@ static void fill_vbos_mesh(const Object &object, hide_poly, attribute, domain, - bke::pbvh::node_faces(nodes[i]), + nodes[i].faces(), *vbos[i]); }); } @@ -1549,7 +1542,7 @@ static Array calc_material_indices(const Object &object) Array node_materials(nodes.size()); threading::parallel_for(nodes.index_range(), 64, [&](const IndexRange range) { for (const int i : range) { - const Span face_indices = bke::pbvh::node_faces(nodes[i]); + const Span face_indices = nodes[i].faces(); if (face_indices.is_empty()) { continue; } @@ -1572,7 +1565,7 @@ static Array calc_material_indices(const Object &object) const Span grid_faces = subdiv_ccg.grid_to_face_map; threading::parallel_for(nodes.index_range(), 64, [&](const IndexRange range) { for (const int i : range) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); if (grids.is_empty()) { continue; } @@ -1609,7 +1602,7 @@ static BitVector<> calc_use_flat_layout(const Object &object, const OrigMeshData Array use_flat_layout(nodes.size()); threading::parallel_for(nodes.index_range(), 4, [&](const IndexRange range) { for (const int i : range) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); if (grids.is_empty()) { continue; } @@ -1718,11 +1711,8 @@ Span DrawCacheImpl::ensure_lines_indices(const Object &object, const bke::AttributeAccessor attributes = orig_mesh_data.attributes; const VArraySpan hide_poly = *attributes.lookup(".hide_poly", bke::AttrDomain::Face); nodes_to_calculate.foreach_index(GrainSize(1), [&](const int i) { - ibos[i] = create_index_faces(faces, - corner_verts, - hide_poly, - bke::pbvh::node_faces(nodes[i]), - nodes[i].vert_indices_); + ibos[i] = create_index_faces( + faces, corner_verts, hide_poly, nodes[i].faces(), nodes[i].vert_indices_); }); break; } @@ -1731,11 +1721,8 @@ Span DrawCacheImpl::ensure_lines_indices(const Object &object, nodes_to_calculate.foreach_index(GrainSize(1), [&](const int i) { const SubdivCCG &subdiv_ccg = *object.sculpt->subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - ibos[i] = create_lines_index_grids(key, - subdiv_ccg.grid_hidden, - coarse, - bke::pbvh::node_grid_indices(nodes[i]), - use_flat_layout_[i]); + ibos[i] = create_lines_index_grids( + key, subdiv_ccg.grid_hidden, coarse, nodes[i].grids(), use_flat_layout_[i]); }); break; } @@ -1780,7 +1767,7 @@ BLI_NOINLINE static void ensure_vbos_allocated_mesh(const Object &object, if (!vbos[i]) { vbos[i] = GPU_vertbuf_create_with_format(format); } - const Span face_indices = bke::pbvh::node_faces(nodes[i]); + const Span face_indices = nodes[i].faces(); const int verts_num = count_visible_tris_mesh(faces, face_indices, hide_poly) * 3; GPU_vertbuf_data_alloc(*vbos[i], verts_num); }); @@ -1802,7 +1789,7 @@ BLI_NOINLINE static void ensure_vbos_allocated_grids(const Object &object, } const int verts_per_grid = use_flat_layout[i] ? square_i(key.grid_size - 1) * 4 : square_i(key.grid_size); - const int verts_num = bke::pbvh::node_grid_indices(nodes[i]).size() * verts_per_grid; + const int verts_num = nodes[i].grids().size() * verts_per_grid; GPU_vertbuf_data_alloc(*vbos[i], verts_num); }); } @@ -1917,11 +1904,8 @@ Span DrawCacheImpl::ensure_tri_indices(const Object &object, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); nodes_to_calculate.foreach_index(GrainSize(1), [&](const int i) { - ibos[i] = create_tri_index_grids(key, - subdiv_ccg.grid_hidden, - coarse, - bke::pbvh::node_grid_indices(nodes[i]), - use_flat_layout_[i]); + ibos[i] = create_tri_index_grids( + key, subdiv_ccg.grid_hidden, coarse, nodes[i].grids(), use_flat_layout_[i]); }); return ibos; } diff --git a/source/blender/editors/sculpt_paint/brushes/clay.cc b/source/blender/editors/sculpt_paint/brushes/clay.cc index af5aa7815ab..4c75a4d7956 100644 --- a/source/blender/editors/sculpt_paint/brushes/clay.cc +++ b/source/blender/editors/sculpt_paint/brushes/clay.cc @@ -70,7 +70,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -113,7 +113,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/clay_strips.cc b/source/blender/editors/sculpt_paint/brushes/clay_strips.cc index 092108da5eb..806e26c5579 100644 --- a/source/blender/editors/sculpt_paint/brushes/clay_strips.cc +++ b/source/blender/editors/sculpt_paint/brushes/clay_strips.cc @@ -56,7 +56,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -110,7 +110,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/clay_thumb.cc b/source/blender/editors/sculpt_paint/brushes/clay_thumb.cc index 41d3bc45e78..c874fd468e3 100644 --- a/source/blender/editors/sculpt_paint/brushes/clay_thumb.cc +++ b/source/blender/editors/sculpt_paint/brushes/clay_thumb.cc @@ -56,7 +56,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); tls.factors.resize(verts.size()); @@ -103,7 +103,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/crease.cc b/source/blender/editors/sculpt_paint/brushes/crease.cc index e8afb6d83ae..f9e9944eb75 100644 --- a/source/blender/editors/sculpt_paint/brushes/crease.cc +++ b/source/blender/editors/sculpt_paint/brushes/crease.cc @@ -82,7 +82,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -137,7 +137,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/draw.cc b/source/blender/editors/sculpt_paint/brushes/draw.cc index 8e1a50344bc..59f509db162 100644 --- a/source/blender/editors/sculpt_paint/brushes/draw.cc +++ b/source/blender/editors/sculpt_paint/brushes/draw.cc @@ -51,7 +51,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -92,7 +92,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/draw_face_sets.cc b/source/blender/editors/sculpt_paint/brushes/draw_face_sets.cc index d680f39f8af..f14fbd39b1f 100644 --- a/source/blender/editors/sculpt_paint/brushes/draw_face_sets.cc +++ b/source/blender/editors/sculpt_paint/brushes/draw_face_sets.cc @@ -182,7 +182,7 @@ static void do_draw_face_sets_brush_mesh(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { MeshLocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span face_indices = bke::pbvh::node_faces(nodes[i]); + const Span face_indices = nodes[i].faces(); calc_faces(depsgraph, object, @@ -235,7 +235,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/draw_sharp.cc b/source/blender/editors/sculpt_paint/brushes/draw_sharp.cc index 546bc08b8d3..982dcc24372 100644 --- a/source/blender/editors/sculpt_paint/brushes/draw_sharp.cc +++ b/source/blender/editors/sculpt_paint/brushes/draw_sharp.cc @@ -50,7 +50,7 @@ static void calc_faces(const Depsgraph &depsgraph, Mesh &mesh = *static_cast(object.data); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -93,7 +93,7 @@ static void calc_grids(const Depsgraph &depsgraph, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); const OrigPositionData orig_data = orig_position_data_get_grids(object, node); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.factors.resize(grid_verts_num); 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 67760f97e73..5530b488912 100644 --- a/source/blender/editors/sculpt_paint/brushes/draw_vector_displacement.cc +++ b/source/blender/editors/sculpt_paint/brushes/draw_vector_displacement.cc @@ -92,7 +92,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -136,7 +136,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/elastic_deform.cc b/source/blender/editors/sculpt_paint/brushes/elastic_deform.cc index de3a76b6a02..a7c648e2c0d 100644 --- a/source/blender/editors/sculpt_paint/brushes/elastic_deform.cc +++ b/source/blender/editors/sculpt_paint/brushes/elastic_deform.cc @@ -100,7 +100,7 @@ static void calc_faces(const Depsgraph &depsgraph, Mesh &mesh = *static_cast(object.data); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -139,7 +139,7 @@ static void calc_grids(const Depsgraph &depsgraph, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); const OrigPositionData orig_data = orig_position_data_get_grids(object, node); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.factors.resize(grid_verts_num); diff --git a/source/blender/editors/sculpt_paint/brushes/enhance_details.cc b/source/blender/editors/sculpt_paint/brushes/enhance_details.cc index b19a8d2636e..17cb659e661 100644 --- a/source/blender/editors/sculpt_paint/brushes/enhance_details.cc +++ b/source/blender/editors/sculpt_paint/brushes/enhance_details.cc @@ -51,7 +51,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -96,7 +96,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); @@ -180,7 +180,7 @@ static void calc_translations_faces(const Span vert_positions, LocalData &tls, const MutableSpan all_translations) { - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.vert_neighbors.resize(verts.size()); const MutableSpan> neighbors = tls.vert_neighbors; @@ -201,7 +201,7 @@ static void calc_translations_grids(const SubdivCCG &subdiv_ccg, LocalData &tls, const MutableSpan all_translations) { - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.new_positions.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/fill.cc b/source/blender/editors/sculpt_paint/brushes/fill.cc index 3a9225cf7b0..734afdabfab 100644 --- a/source/blender/editors/sculpt_paint/brushes/fill.cc +++ b/source/blender/editors/sculpt_paint/brushes/fill.cc @@ -53,7 +53,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -101,7 +101,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/flatten.cc b/source/blender/editors/sculpt_paint/brushes/flatten.cc index 1ea4fd17d18..d8f7c7dc3f4 100644 --- a/source/blender/editors/sculpt_paint/brushes/flatten.cc +++ b/source/blender/editors/sculpt_paint/brushes/flatten.cc @@ -52,7 +52,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -98,7 +98,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/grab.cc b/source/blender/editors/sculpt_paint/brushes/grab.cc index 6e3d543a5ba..ab5e817998b 100644 --- a/source/blender/editors/sculpt_paint/brushes/grab.cc +++ b/source/blender/editors/sculpt_paint/brushes/grab.cc @@ -64,7 +64,7 @@ static void calc_faces(const Depsgraph &depsgraph, Mesh &mesh = *static_cast(object.data); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -111,7 +111,7 @@ static void calc_grids(const Depsgraph &depsgraph, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); const OrigPositionData orig_data = orig_position_data_get_grids(object, node); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.factors.resize(grid_verts_num); diff --git a/source/blender/editors/sculpt_paint/brushes/inflate.cc b/source/blender/editors/sculpt_paint/brushes/inflate.cc index 56cb7c2316f..dc764c36663 100644 --- a/source/blender/editors/sculpt_paint/brushes/inflate.cc +++ b/source/blender/editors/sculpt_paint/brushes/inflate.cc @@ -58,7 +58,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -99,7 +99,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/layer.cc b/source/blender/editors/sculpt_paint/brushes/layer.cc index 0f2547c029b..413866df6c8 100644 --- a/source/blender/editors/sculpt_paint/brushes/layer.cc +++ b/source/blender/editors/sculpt_paint/brushes/layer.cc @@ -133,7 +133,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); tls.factors.resize(verts.size()); @@ -227,7 +227,7 @@ static void calc_grids(const Depsgraph &depsgraph, SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/mask.cc b/source/blender/editors/sculpt_paint/brushes/mask.cc index 2ac3bdbcfe7..75b0d46ec47 100644 --- a/source/blender/editors/sculpt_paint/brushes/mask.cc +++ b/source/blender/editors/sculpt_paint/brushes/mask.cc @@ -74,7 +74,7 @@ static void calc_faces(const Depsgraph &depsgraph, SculptSession &ss = *object.sculpt; const StrokeCache &cache = *ss.cache; - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -121,7 +121,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/multiplane_scrape.cc b/source/blender/editors/sculpt_paint/brushes/multiplane_scrape.cc index fcc807c3713..20a475ef7f8 100644 --- a/source/blender/editors/sculpt_paint/brushes/multiplane_scrape.cc +++ b/source/blender/editors/sculpt_paint/brushes/multiplane_scrape.cc @@ -139,7 +139,7 @@ static void sample_node_surface_mesh(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(vert_positions, verts, tls.positions); tls.factors.resize(verts.size()); @@ -182,7 +182,7 @@ static void sample_node_surface_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); @@ -352,7 +352,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); tls.factors.resize(verts.size()); @@ -410,7 +410,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); 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 72782479c90..ee18f082d41 100644 --- a/source/blender/editors/sculpt_paint/brushes/multires_displacement_eraser.cc +++ b/source/blender/editors/sculpt_paint/brushes/multires_displacement_eraser.cc @@ -57,7 +57,7 @@ static void calc_node(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); 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 7095b480437..60be9e3362a 100644 --- a/source/blender/editors/sculpt_paint/brushes/multires_displacement_smear.cc +++ b/source/blender/editors/sculpt_paint/brushes/multires_displacement_smear.cc @@ -46,7 +46,7 @@ static void calc_node(const Depsgraph &depsgraph, const Span elems = subdiv_ccg.grids; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); @@ -160,7 +160,7 @@ BLI_NOINLINE static void store_node_prev_displacement(const Span limit_p const bke::pbvh::GridsNode &node, const MutableSpan prev_displacement) { - for (const int grid : bke::pbvh::node_grid_indices(node)) { + for (const int grid : node.grids()) { const int start = grid * key.grid_area; CCGElem *elem = elems[grid]; for (const int i : IndexRange(key.grid_area)) { diff --git a/source/blender/editors/sculpt_paint/brushes/pinch.cc b/source/blender/editors/sculpt_paint/brushes/pinch.cc index 88c9ba44d96..265b2fafae3 100644 --- a/source/blender/editors/sculpt_paint/brushes/pinch.cc +++ b/source/blender/editors/sculpt_paint/brushes/pinch.cc @@ -76,7 +76,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); tls.factors.resize(verts.size()); @@ -125,7 +125,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/relax.cc b/source/blender/editors/sculpt_paint/brushes/relax.cc index af4b6fb1d11..ea2fd29bb53 100644 --- a/source/blender/editors/sculpt_paint/brushes/relax.cc +++ b/source/blender/editors/sculpt_paint/brushes/relax.cc @@ -114,7 +114,7 @@ BLI_NOINLINE static void calc_factors_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); fill_factor_from_hide_and_mask(mesh, verts, factors); filter_region_clip_factors(ss, positions_eval, verts, factors); @@ -194,7 +194,7 @@ static void do_relax_face_sets_brush_mesh(const Depsgraph &depsgraph, ss.face_sets, hide_poly, relax_face_sets, - bke::pbvh::node_unique_verts(nodes[i]), + nodes[i].verts(), factors.as_span().slice(node_vert_offsets[pos]), tls.vert_neighbors, translations.as_mutable_span().slice(node_vert_offsets[pos])); @@ -204,7 +204,7 @@ static void do_relax_face_sets_brush_mesh(const Depsgraph &depsgraph, apply_positions_faces(depsgraph, sd, positions_eval, - bke::pbvh::node_unique_verts(nodes[i]), + nodes[i].verts(), object, translations.as_mutable_span().slice(node_vert_offsets[pos]), positions_orig); @@ -228,7 +228,7 @@ BLI_NOINLINE static void calc_factors_grids(const Depsgraph &depsgraph, SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; gather_grids_positions(key, subdiv_ccg.grids, grids, positions); @@ -314,7 +314,7 @@ static void do_relax_face_sets_brush_grids(const Depsgraph &depsgraph, ss.face_sets, ss.vert_to_face_map, ss.vertex_info.boundary, - bke::pbvh::node_grid_indices(nodes[i]), + nodes[i].grids(), relax_face_sets, factors.as_span().slice(node_vert_offsets[pos]), current_positions.as_span().slice(node_vert_offsets[pos]), @@ -324,7 +324,7 @@ static void do_relax_face_sets_brush_grids(const Depsgraph &depsgraph, node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { apply_positions_grids(sd, - bke::pbvh::node_grid_indices(nodes[i]), + nodes[i].grids(), object, current_positions.as_mutable_span().slice(node_vert_offsets[pos]), translations.as_mutable_span().slice(node_vert_offsets[pos])); @@ -439,7 +439,7 @@ BLI_NOINLINE static void calc_topology_relax_factors_faces(const Depsgraph &deps const Mesh &mesh = *static_cast(object.data); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); fill_factor_from_hide_and_mask(mesh, verts, factors); filter_region_clip_factors(ss, orig_data.positions, factors); @@ -512,7 +512,7 @@ static void do_topology_relax_brush_mesh(const Depsgraph &depsgraph, ss.face_sets, hide_poly, false, - bke::pbvh::node_unique_verts(nodes[i]), + nodes[i].verts(), factors.as_span().slice(node_vert_offsets[pos]), tls.vert_neighbors, translations.as_mutable_span().slice(node_vert_offsets[pos])); @@ -522,7 +522,7 @@ static void do_topology_relax_brush_mesh(const Depsgraph &depsgraph, apply_positions_faces(depsgraph, sd, positions_eval, - bke::pbvh::node_unique_verts(nodes[i]), + nodes[i].verts(), object, translations.as_mutable_span().slice(node_vert_offsets[pos]), positions_orig); @@ -543,7 +543,7 @@ BLI_NOINLINE static void calc_topology_relax_factors_grids(const Depsgraph &deps const SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; gather_grids_positions(key, subdiv_ccg.grids, grids, positions); @@ -619,7 +619,7 @@ static void do_topology_relax_brush_grids(const Depsgraph &depsgraph, ss.face_sets, ss.vert_to_face_map, ss.vertex_info.boundary, - bke::pbvh::node_grid_indices(nodes[i]), + nodes[i].grids(), false, factors.as_span().slice(node_vert_offsets[pos]), current_positions.as_span().slice(node_vert_offsets[pos]), @@ -629,7 +629,7 @@ static void do_topology_relax_brush_grids(const Depsgraph &depsgraph, node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { apply_positions_grids(sd, - bke::pbvh::node_grid_indices(nodes[i]), + nodes[i].grids(), object, current_positions.as_mutable_span().slice(node_vert_offsets[pos]), translations.as_mutable_span().slice(node_vert_offsets[pos])); diff --git a/source/blender/editors/sculpt_paint/brushes/rotate.cc b/source/blender/editors/sculpt_paint/brushes/rotate.cc index 68088bffcf6..020564005bf 100644 --- a/source/blender/editors/sculpt_paint/brushes/rotate.cc +++ b/source/blender/editors/sculpt_paint/brushes/rotate.cc @@ -68,7 +68,7 @@ static void calc_faces(const Depsgraph &depsgraph, Mesh &mesh = *static_cast(object.data); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -114,7 +114,7 @@ static void calc_grids(const Depsgraph &depsgraph, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); const OrigPositionData orig_data = orig_position_data_get_grids(object, node); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.factors.resize(grid_verts_num); diff --git a/source/blender/editors/sculpt_paint/brushes/scrape.cc b/source/blender/editors/sculpt_paint/brushes/scrape.cc index f994b048bf5..02fb6067ae1 100644 --- a/source/blender/editors/sculpt_paint/brushes/scrape.cc +++ b/source/blender/editors/sculpt_paint/brushes/scrape.cc @@ -53,7 +53,7 @@ static void calc_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -101,7 +101,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/smooth.cc b/source/blender/editors/sculpt_paint/brushes/smooth.cc index fa0b6a2c1b9..290fcac8242 100644 --- a/source/blender/editors/sculpt_paint/brushes/smooth.cc +++ b/source/blender/editors/sculpt_paint/brushes/smooth.cc @@ -70,7 +70,7 @@ BLI_NOINLINE static void apply_positions_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -134,7 +134,7 @@ BLI_NOINLINE static void do_smooth_brush_mesh(const Depsgraph &depsgraph, for (const float strength : iteration_strengths(brush_strength)) { node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { LocalData &tls = all_tls.local(); - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.vert_neighbors.resize(verts.size()); calc_vert_neighbors_interior(faces, corner_verts, @@ -182,7 +182,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/smooth_mask.cc b/source/blender/editors/sculpt_paint/brushes/smooth_mask.cc index 6eb88199709..65dffdfc25a 100644 --- a/source/blender/editors/sculpt_paint/brushes/smooth_mask.cc +++ b/source/blender/editors/sculpt_paint/brushes/smooth_mask.cc @@ -81,7 +81,7 @@ static void apply_masks_faces(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -153,7 +153,7 @@ static void do_smooth_brush_mesh(const Depsgraph &depsgraph, corner_verts, ss.vert_to_face_map, hide_poly, - bke::pbvh::node_unique_verts(nodes[i]), + nodes[i].verts(), mask.span.as_span(), tls, new_masks.as_mutable_span().slice(node_vert_offsets[pos])); @@ -187,7 +187,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/snake_hook.cc b/source/blender/editors/sculpt_paint/brushes/snake_hook.cc index 01215951969..0fef9b204e1 100644 --- a/source/blender/editors/sculpt_paint/brushes/snake_hook.cc +++ b/source/blender/editors/sculpt_paint/brushes/snake_hook.cc @@ -172,7 +172,7 @@ static void calc_faces(const Depsgraph &depsgraph, const bool do_elastic = brush.snake_hook_deform_type == BRUSH_SNAKE_HOOK_DEFORM_ELASTIC; Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); tls.factors.resize(verts.size()); @@ -233,7 +233,7 @@ static void calc_grids(const Depsgraph &depsgraph, const bool do_elastic = brush.snake_hook_deform_type == BRUSH_SNAKE_HOOK_DEFORM_ELASTIC; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/brushes/surface_smooth.cc b/source/blender/editors/sculpt_paint/brushes/surface_smooth.cc index c0e5b9781d1..95e5af729aa 100644 --- a/source/blender/editors/sculpt_paint/brushes/surface_smooth.cc +++ b/source/blender/editors/sculpt_paint/brushes/surface_smooth.cc @@ -75,7 +75,7 @@ BLI_NOINLINE static void do_surface_smooth_brush_mesh(const Depsgraph &depsgraph threading::EnumerableThreadSpecific all_tls; node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { LocalData &tls = all_tls.local(); - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const MutableSpan factors = all_factors.as_mutable_span().slice(node_offsets[pos]); fill_factor_from_hide_and_mask(mesh, verts, factors); @@ -104,7 +104,7 @@ BLI_NOINLINE static void do_surface_smooth_brush_mesh(const Depsgraph &depsgraph for ([[maybe_unused]] const int iteration : IndexRange(brush.surface_smooth_iterations)) { node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { LocalData &tls = all_tls.local(); - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); const OrigPositionData orig_data = orig_position_data_get_mesh(object, nodes[i]); const Span factors = all_factors.as_span().slice(node_offsets[pos]); @@ -133,7 +133,7 @@ BLI_NOINLINE static void do_surface_smooth_brush_mesh(const Depsgraph &depsgraph node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { LocalData &tls = all_tls.local(); - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const Span factors = all_factors.as_span().slice(node_offsets[pos]); const MutableSpan laplacian_disp = gather_data_mesh( @@ -184,7 +184,7 @@ BLI_NOINLINE static void do_surface_smooth_brush_grids( threading::EnumerableThreadSpecific all_tls; node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { LocalData &tls = all_tls.local(); - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const MutableSpan factors = all_factors.as_mutable_span().slice(node_offsets[pos]); @@ -213,7 +213,7 @@ BLI_NOINLINE static void do_surface_smooth_brush_grids( for ([[maybe_unused]] const int iteration : IndexRange(brush.surface_smooth_iterations)) { node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { LocalData &tls = all_tls.local(); - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); const Span factors = all_factors.as_span().slice(node_offsets[pos]); @@ -238,7 +238,7 @@ BLI_NOINLINE static void do_surface_smooth_brush_grids( node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { LocalData &tls = all_tls.local(); - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const Span factors = all_factors.as_span().slice(node_offsets[pos]); diff --git a/source/blender/editors/sculpt_paint/brushes/thumb.cc b/source/blender/editors/sculpt_paint/brushes/thumb.cc index 6154084d8b0..18d337dbfa9 100644 --- a/source/blender/editors/sculpt_paint/brushes/thumb.cc +++ b/source/blender/editors/sculpt_paint/brushes/thumb.cc @@ -50,7 +50,7 @@ static void calc_faces(const Depsgraph &depsgraph, Mesh &mesh = *static_cast(object.data); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -94,7 +94,7 @@ static void calc_grids(const Depsgraph &depsgraph, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); const OrigPositionData orig_data = orig_position_data_get_grids(object, node); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.factors.resize(grid_verts_num); diff --git a/source/blender/editors/sculpt_paint/brushes/topology_slide.cc b/source/blender/editors/sculpt_paint/brushes/topology_slide.cc index 17d47b6e202..d029cf18b2f 100644 --- a/source/blender/editors/sculpt_paint/brushes/topology_slide.cc +++ b/source/blender/editors/sculpt_paint/brushes/topology_slide.cc @@ -170,7 +170,7 @@ static void calc_faces(const Depsgraph &depsgraph, Mesh &mesh = *static_cast(object.data); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); tls.factors.resize(verts.size()); @@ -220,7 +220,7 @@ static void calc_grids(const Depsgraph &depsgraph, SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const OrigPositionData orig_data = orig_position_data_get_grids(object, node); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/paint_hide.cc b/source/blender/editors/sculpt_paint/paint_hide.cc index 1f86f7d70e1..f3a05489ec8 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.cc +++ b/source/blender/editors/sculpt_paint/paint_hide.cc @@ -134,7 +134,7 @@ void mesh_show_all(const Depsgraph &depsgraph, Object &object, const IndexMask & IndexMaskMemory memory; const IndexMask changed_nodes = IndexMask::from_predicate( node_mask, GrainSize(1), memory, [&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); return std::any_of( verts.begin(), verts.end(), [&](const int i) { return hide_vert[i]; }); }); @@ -158,7 +158,7 @@ void grids_show_all(Depsgraph &depsgraph, Object &object, const IndexMask &node_ IndexMaskMemory memory; const IndexMask changed_nodes = IndexMask::from_predicate( node_mask, GrainSize(1), memory, [&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); return std::any_of(grids.begin(), grids.end(), [&](const int i) { return bits::any_bit_set(grid_hidden[i]); }); @@ -228,7 +228,7 @@ static void flush_face_changes_node(Mesh &mesh, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { TLS &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span node_faces = bke::pbvh::node_faces(nodes[i]); + const Span node_faces = nodes[i].faces(); tls.new_hide.resize(node_faces.size()); gather_data_mesh(hide_poly.span.as_span(), node_faces, tls.new_hide.as_mutable_span()); @@ -288,7 +288,7 @@ static void vert_hide_update(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { Vector &new_hide = all_new_hide.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); new_hide.resize(verts.size()); gather_data_mesh(hide_vert.span.as_span(), verts, new_hide.as_mutable_span()); @@ -327,7 +327,7 @@ static void grid_hide_update(Depsgraph &depsgraph, bool any_changed = false; threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); BitGroupVector<> new_hide(grids.size(), grid_hidden.group_size()); for (const int i : grids.index_range()) { new_hide[i].copy_from(grid_hidden[grids[i]].as_span()); @@ -718,7 +718,7 @@ static void invert_visibility_mesh(const Depsgraph &depsgraph, undo::push_nodes(depsgraph, object, node_mask, undo::Type::HideFace); node_mask.foreach_index(GrainSize(1), [&](const int i) { - for (const int face : bke::pbvh::node_faces(nodes[i])) { + for (const int face : nodes[i].faces()) { hide_poly.span[face] = !hide_poly.span[face]; } BKE_pbvh_node_mark_update_visibility(nodes[i]); @@ -741,7 +741,7 @@ static void invert_visibility_grids(Depsgraph &depsgraph, BitGroupVector<> &grid_hidden = BKE_subdiv_ccg_grid_hidden_ensure(subdiv_ccg); node_mask.foreach_index(GrainSize(1), [&](const int i) { - for (const int i : bke::pbvh::node_grid_indices(nodes[i])) { + for (const int i : nodes[i].grids()) { bits::invert(grid_hidden[i]); } BKE_pbvh_node_mark_update_visibility(nodes[i]); @@ -900,7 +900,7 @@ static void update_undo_state(const Depsgraph &depsgraph, const Span nodes = ss.pbvh->nodes(); node_mask.foreach_index(GrainSize(1), [&](const int i) { - for (const int vert : bke::pbvh::node_unique_verts(nodes[i])) { + for (const int vert : nodes[i].verts()) { if (old_hide_vert[vert] != new_hide_vert[vert]) { undo::push_node(depsgraph, object, &nodes[i], undo::Type::HideVert); break; @@ -917,7 +917,7 @@ static void update_node_visibility_from_face_changes(MutableSpan indices = bke::pbvh::node_faces(nodes[i]); + const Span indices = nodes[i].faces(); for (const int face_index : indices) { if (orig_hide_poly[face_index] != new_hide_poly[face_index]) { any_changed = true; @@ -1018,7 +1018,7 @@ static void grow_shrink_visibility_grid(Depsgraph &depsgraph, BitGroupVector<> &write_buffer = buffers.write_buffer(i); node_mask.foreach_index(GrainSize(1), [&](const int i) { - for (const int grid : bke::pbvh::node_grid_indices(nodes[i])) { + for (const int grid : nodes[i].grids()) { for (const int y : IndexRange(key.grid_size)) { for (const int x : IndexRange(key.grid_size)) { const int grid_elem_idx = CCG_grid_xy_to_index(key.grid_size, x, y); diff --git a/source/blender/editors/sculpt_paint/paint_mask.cc b/source/blender/editors/sculpt_paint/paint_mask.cc index 150ee93b5c6..b6d3554bb19 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.cc +++ b/source/blender/editors/sculpt_paint/paint_mask.cc @@ -372,7 +372,7 @@ static Span get_hidden_verts(const bke::pbvh::MeshNode &node, if (hide_vert.is_empty()) { return {}; } - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); if (BKE_pbvh_node_fully_hidden_get(node)) { return verts; } @@ -430,7 +430,7 @@ static bool try_remove_mask_mesh(const Depsgraph &depsgraph, /* Store undo data for nodes with changed mask. */ node_mask.foreach_index(GrainSize(1), [&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); if (std::all_of(verts.begin(), verts.end(), [&](const int i) { return mask[i] == 0.0f; })) { return; } @@ -515,7 +515,7 @@ static void fill_mask_grids(Main &bmain, const Span grids = subdiv_ccg.grids; bool any_changed = false; node_mask.foreach_index(GrainSize(1), [&](const int i) { - const Span grid_indices = bke::pbvh::node_grid_indices(nodes[i]); + const Span grid_indices = nodes[i].grids(); if (std::all_of(grid_indices.begin(), grid_indices.end(), [&](const int grid) { CCGElem *elem = grids[grid]; for (const int i : IndexRange(key.grid_area)) { @@ -640,7 +640,7 @@ static void invert_mask_grids(Main &bmain, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); const Span grids = subdiv_ccg.grids; node_mask.foreach_index(GrainSize(1), [&](const int i) { - const Span grid_indices = bke::pbvh::node_grid_indices(nodes[i]); + const Span grid_indices = nodes[i].grids(); if (grid_hidden.is_empty()) { for (const int grid : grid_indices) { CCGElem *elem = grids[grid]; @@ -835,7 +835,7 @@ static void gesture_apply_for_symmetry_pass(bContext & /*C*/, gesture::GestureDa threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { node_mask.slice(range).foreach_index([&](const int i) { bool any_changed = false; - for (const int grid : bke::pbvh::node_grid_indices(nodes[i])) { + for (const int grid : nodes[i].grids()) { CCGElem *elem = grids[grid]; BKE_subdiv_ccg_foreach_visible_grid_vert(key, grid_hidden, grid, [&](const int i) { if (gesture::is_affected(gesture_data, diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index a840d997ab9..72f3c9c2f64 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -1093,7 +1093,7 @@ static void do_vpaint_brush_blur_loops(const bContext *C, blender::threading::parallel_for(node_mask.index_range(), 1LL, [&](IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide(mesh, verts, factors); @@ -1251,7 +1251,7 @@ static void do_vpaint_brush_blur_verts(const bContext *C, blender::threading::parallel_for(node_mask.index_range(), 1LL, [&](IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide(mesh, verts, factors); @@ -1412,7 +1412,7 @@ static void do_vpaint_brush_smear(const bContext *C, blender::threading::parallel_for(node_mask.index_range(), 1LL, [&](IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide(mesh, verts, factors); @@ -1598,7 +1598,7 @@ static void calculate_average_color(VPaintData &vpd, accum2.len = 0; memset(accum2.value, 0, sizeof(accum2.value)); - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide(mesh, verts, factors); @@ -1729,7 +1729,7 @@ static void vpaint_do_draw(const bContext *C, blender::threading::parallel_for(node_mask.index_range(), 1LL, [&](IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide(mesh, verts, factors); diff --git a/source/blender/editors/sculpt_paint/paint_weight.cc b/source/blender/editors/sculpt_paint/paint_weight.cc index 36a606417a4..39ed0ff455a 100644 --- a/source/blender/editors/sculpt_paint/paint_weight.cc +++ b/source/blender/editors/sculpt_paint/paint_weight.cc @@ -1135,7 +1135,7 @@ static void do_wpaint_brush_blur(const Depsgraph &depsgraph, parallel_nodes_loop_with_mirror_check(mesh, node_mask, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide(mesh, verts, factors); @@ -1253,7 +1253,7 @@ static void do_wpaint_brush_smear(const Depsgraph &depsgraph, parallel_nodes_loop_with_mirror_check(mesh, node_mask, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide(mesh, verts, factors); @@ -1370,7 +1370,7 @@ static void do_wpaint_brush_draw(const Depsgraph &depsgraph, parallel_nodes_loop_with_mirror_check(mesh, node_mask, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide(mesh, verts, factors); @@ -1457,7 +1457,7 @@ static float calculate_average_weight(const Depsgraph &depsgraph, [&](const IndexRange range, WPaintAverageAccum accum) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide(mesh, verts, factors); diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 263226ff202..6e31a81dc3c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -863,7 +863,7 @@ std::optional nearest_vert_calc_mesh(const bke::pbvh::Tree &pbvh, NearestData(), [&](const IndexRange range, NearestData nearest) { nodes_in_sphere.slice(range).foreach_index([&](const int i) { - for (const int vert : bke::pbvh::node_unique_verts(nodes[i])) { + for (const int vert : nodes[i].verts()) { if (!hide_vert.is_empty() && hide_vert[vert]) { continue; } @@ -913,7 +913,7 @@ std::optional nearest_vert_calc_grids(const bke::pbvh::Tree &pbv NearestData(), [&](const IndexRange range, NearestData nearest) { nodes_in_sphere.slice(range).foreach_index([&](const int i) { - for (const int grid : bke::pbvh::node_grid_indices(nodes[i])) { + for (const int grid : nodes[i].grids()) { CCGElem *elem = elems[grid]; BKE_subdiv_ccg_foreach_visible_grid_vert(key, grid_hidden, grid, [&](const int i) { const float distance_sq = math::distance_squared(CCG_elem_offset_co(key, elem, i), @@ -1177,7 +1177,7 @@ static void restore_mask_from_undo_step(Object &object) if (const std::optional> orig_data = orig_mask_data_lookup_mesh(object, nodes[i])) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); array_utils::scatter(*orig_data, verts, mask.span); BKE_pbvh_node_mark_update_mask(nodes[i]); } @@ -1211,7 +1211,7 @@ static void restore_mask_from_undo_step(Object &object) nodes[i])) { int index = 0; - for (const int grid : bke::pbvh::node_grid_indices(nodes[i])) { + for (const int grid : nodes[i].grids()) { CCGElem *elem = grids[grid]; for (const int i : IndexRange(key.grid_area)) { if (grid_hidden.is_empty() || !grid_hidden[grid][i]) { @@ -1245,7 +1245,7 @@ static void restore_color_from_undo_step(Object &object) if (const std::optional> orig_data = orig_color_data_lookup_mesh(object, nodes[i])) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); for (const int i : verts.index_range()) { color::color_vert_set(faces, corner_verts, @@ -1274,7 +1274,7 @@ static void restore_face_set_from_undo_step(Object &object) if (const std::optional> orig_data = orig_face_set_data_lookup_mesh(object, nodes[i])) { - scatter_data_mesh(*orig_data, bke::pbvh::node_faces(nodes[i]), attribute.span); + scatter_data_mesh(*orig_data, nodes[i].faces(), attribute.span); BKE_pbvh_node_mark_update_face_sets(nodes[i]); } }); @@ -1332,7 +1332,7 @@ void restore_position_from_undo_step(const Depsgraph &depsgraph, Object &object) if (const std::optional orig_data = orig_position_data_lookup_mesh( object, nodes[i])) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const Span undo_positions = orig_data->positions; if (need_translations) { tls.translations.resize(verts.size()); @@ -1398,7 +1398,7 @@ void restore_position_from_undo_step(const Depsgraph &depsgraph, Object &object) object, nodes[i])) { int index = 0; - for (const int grid : bke::pbvh::node_grid_indices(nodes[i])) { + for (const int grid : nodes[i].grids()) { CCGElem *elem = grids[grid]; for (const int i : IndexRange(key.grid_area)) { if (grid_hidden.is_empty() || !grid_hidden[grid][i]) { @@ -1698,7 +1698,7 @@ static void calc_area_normal_and_center_node_mesh(const Object &object, const float normal_radius_sq = normal_radius * normal_radius; const float normal_radius_inv = math::rcp(normal_radius); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); if (ss.cache && !ss.cache->accum) { if (const std::optional orig_data = orig_position_data_get_mesh(object, @@ -1787,7 +1787,7 @@ static void calc_area_normal_and_center_node_grids(const Object &object, const CCGKey key = BKE_subdiv_ccg_key_top_level(*ss.subdiv_ccg); const Span elems = subdiv_ccg.grids; const BitGroupVector<> &grid_hidden = subdiv_ccg.grid_hidden; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); if (ss.cache && !ss.cache->accum) { if (const std::optional orig_data = orig_position_data_get_grids(object, @@ -5922,7 +5922,7 @@ static void fake_neighbor_search_mesh(const SculptSession &ss, const bke::pbvh::MeshNode &node, NearestVertData &nvtd) { - for (const int vert : bke::pbvh::node_unique_verts(node)) { + for (const int vert : node.verts()) { if (!hide_vert.is_empty() && hide_vert[vert]) { continue; } @@ -5950,7 +5950,7 @@ static void fake_neighbor_search_grids(const SculptSession &ss, const bke::pbvh::GridsNode &node, NearestVertData &nvtd) { - for (const int grid : bke::pbvh::node_grid_indices(node)) { + for (const int grid : node.grids()) { const int verts_start = grid * key.grid_area; CCGElem *elem = elems[grid]; BKE_subdiv_ccg_foreach_visible_grid_vert(key, grid_hidden, grid, [&](const int offset) { @@ -7463,9 +7463,8 @@ OffsetIndices create_node_vert_offsets(const Span node Array &node_data) { node_data.reinitialize(node_mask.size() + 1); - node_mask.foreach_index([&](const int i, const int pos) { - node_data[pos] = bke::pbvh::node_unique_verts(nodes[i]).size(); - }); + node_mask.foreach_index( + [&](const int i, const int pos) { node_data[pos] = nodes[i].verts().size(); }); return offset_indices::accumulate_counts_to_offsets(node_data); } @@ -7476,7 +7475,7 @@ OffsetIndices create_node_vert_offsets(const CCGKey &key, { node_data.reinitialize(node_mask.size() + 1); node_mask.foreach_index([&](const int i, const int pos) { - node_data[pos] = bke::pbvh::node_grid_indices(nodes[i]).size() * key.grid_area; + node_data[pos] = nodes[i].grids().size() * key.grid_area; }); return offset_indices::accumulate_counts_to_offsets(node_data); } diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.cc b/source/blender/editors/sculpt_paint/sculpt_boundary.cc index 56ddadb1577..13634ed8d68 100644 --- a/source/blender/editors/sculpt_paint/sculpt_boundary.cc +++ b/source/blender/editors/sculpt_paint/sculpt_boundary.cc @@ -1131,7 +1131,7 @@ static void calc_bend_mesh(const Depsgraph &depsgraph, SculptSession &ss = *object.sculpt; const StrokeCache &cache = *ss.cache; - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(object); @@ -1191,7 +1191,7 @@ static void calc_bend_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; const OrigPositionData orig_data = orig_position_data_get_grids(object, node); @@ -1426,7 +1426,7 @@ static void calc_slide_mesh(const Depsgraph &depsgraph, SculptSession &ss = *object.sculpt; const StrokeCache &cache = *ss.cache; - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(object); @@ -1485,7 +1485,7 @@ static void calc_slide_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; const OrigPositionData orig_data = orig_position_data_get_grids(object, node); @@ -1713,7 +1713,7 @@ static void calc_inflate_mesh(const Depsgraph &depsgraph, SculptSession &ss = *object.sculpt; const StrokeCache &cache = *ss.cache; - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(object); @@ -1767,7 +1767,7 @@ static void calc_inflate_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; const OrigPositionData orig_data = orig_position_data_get_grids(object, node); @@ -1984,7 +1984,7 @@ static void calc_grab_mesh(const Depsgraph &depsgraph, SculptSession &ss = *object.sculpt; const StrokeCache &cache = *ss.cache; - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(object); @@ -2039,7 +2039,7 @@ static void calc_grab_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; const OrigPositionData orig_data = orig_position_data_get_grids(object, node); @@ -2262,7 +2262,7 @@ static void calc_twist_mesh(const Depsgraph &depsgraph, SculptSession &ss = *object.sculpt; const StrokeCache &cache = *ss.cache; - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(object); @@ -2319,7 +2319,7 @@ static void calc_twist_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; const OrigPositionData orig_data = orig_position_data_get_grids(object, node); @@ -2636,7 +2636,7 @@ static void calc_smooth_mesh(const Depsgraph &depsgraph, SculptSession &ss = *object.sculpt; const StrokeCache &cache = *ss.cache; - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); const ePaintSymmetryFlags symm = SCULPT_mesh_symmetry_xyz_get(object); @@ -2702,7 +2702,7 @@ static void calc_smooth_grids(const Sculpt &sd, const StrokeCache &cache = *ss.cache; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; const OrigPositionData orig_data = orig_position_data_get_grids(object, node); diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.cc b/source/blender/editors/sculpt_paint/sculpt_cloth.cc index 2e722c8e17b..fdee934c228 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.cc @@ -553,7 +553,7 @@ void ensure_nodes_constraints(const Sculpt &sd, const BitGroupVector<> &grid_hidden = subdiv_ccg.grid_hidden; uninitialized_nodes.foreach_index([&](const int i) { const Span verts = calc_visible_vert_indices_grids( - key, grid_hidden, bke::pbvh::node_grid_indices(nodes[i]), vert_indices); + key, grid_hidden, nodes[i].grids(), vert_indices); vert_neighbors.resize(verts.size()); calc_vert_neighbor_indices_grids(subdiv_ccg, verts, vert_neighbors); add_constraints_for_verts(object, @@ -738,7 +738,7 @@ static void calc_forces_mesh(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const Mesh &mesh = *static_cast(ob.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); const MutableSpan init_positions = gather_data_mesh( cloth_sim.init_pos.as_span(), verts, tls.init_positions); @@ -846,7 +846,7 @@ static void calc_forces_grids(const Depsgraph &depsgraph, const SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const MutableSpan init_positions = gather_data_grids( subdiv_ccg, cloth_sim.init_pos.as_span(), grids, tls.init_positions); @@ -1242,7 +1242,7 @@ static void calc_constraint_factors(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; fill_factor_from_hide_and_mask(mesh, verts, factors); @@ -1264,7 +1264,7 @@ static void calc_constraint_factors(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.factors.resize(grid_verts_num); const MutableSpan factors = tls.factors; @@ -1409,7 +1409,7 @@ void do_simulation_step(const Depsgraph &depsgraph, threading::parallel_for(active_nodes.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); active_nodes.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -1446,7 +1446,7 @@ void do_simulation_step(const Depsgraph &depsgraph, threading::parallel_for(active_nodes.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); active_nodes.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.factors.resize(grid_verts_num); @@ -1694,7 +1694,7 @@ static void copy_positions_to_array(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 8, [&](const IndexRange range) { Vector node_positions; node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); gather_grids_positions(subdiv_ccg, grids, node_positions); scatter_data_grids(subdiv_ccg, node_positions.as_span(), grids, positions); }); @@ -1726,7 +1726,7 @@ static void copy_normals_to_array(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 8, [&](const IndexRange range) { Vector node_normals; node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const int grid_verts_num = grids.size() * key.grid_area; node_normals.resize(grid_verts_num); @@ -2089,7 +2089,7 @@ static void apply_filter_forces_mesh(const Depsgraph &depsgraph, SimulationData &cloth_sim = *ss.filter_cache->cloth_sim; const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -2158,7 +2158,7 @@ static void apply_filter_forces_grids(const Depsgraph &depsgraph, const SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.factors.resize(grid_verts_num); diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.cc b/source/blender/editors/sculpt_paint/sculpt_expand.cc index e6e95ddd8fe..fe4b4d2a038 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.cc +++ b/source/blender/editors/sculpt_paint/sculpt_expand.cc @@ -1462,7 +1462,7 @@ static void restore_color_data(Object &ob, Cache &expand_cache) const GroupedSpan vert_to_face_map = ss.vert_to_face_map; bke::GSpanAttributeWriter color_attribute = color::active_color_attribute_for_write(mesh); node_mask.foreach_index([&](const int i) { - for (const int vert : bke::pbvh::node_unique_verts(nodes[i])) { + for (const int vert : nodes[i].verts()) { color::color_vert_set(faces, corner_verts, vert_to_face_map, @@ -1612,7 +1612,7 @@ static void update_mask_grids(const SculptSession &ss, const Span elems = subdiv_ccg.grids; bool any_changed = false; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); for (const int i : grids.index_range()) { const int grid = grids[i]; const int start = grid * key.grid_area; @@ -1755,7 +1755,7 @@ static void colors_update_task(const Depsgraph &depsgraph, const BitVector<> enabled_verts = enabled_state_to_bitmap(depsgraph, object, expand_cache); bool any_changed = false; - const Span verts = bke::pbvh::node_unique_verts(*node); + const Span verts = node->verts(); for (const int i : verts.index_range()) { const int vert = verts[i]; if (!hide_vert.is_empty() && hide_vert[vert]) { diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.cc b/source/blender/editors/sculpt_paint/sculpt_face_set.cc index db4a8bc29c3..dff14700254 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.cc +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.cc @@ -303,7 +303,7 @@ static void face_sets_update(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { TLS &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span faces = bke::pbvh::node_faces(nodes[i]); + const Span faces = nodes[i].faces(); tls.new_face_sets.resize(faces.size()); MutableSpan new_face_sets = tls.new_face_sets; @@ -366,7 +366,7 @@ static void clear_face_sets(const Depsgraph &depsgraph, Object &object, const In if (pbvh.type() == bke::pbvh::Type::Mesh) { MutableSpan nodes = ss.pbvh->nodes(); node_mask.foreach_index(GrainSize(1), [&](const int i) { - const Span faces = bke::pbvh::node_faces(nodes[i]); + const Span faces = nodes[i].faces(); if (std::any_of(faces.begin(), faces.end(), [&](const int face) { return face_sets[face] != default_face_set; })) @@ -889,7 +889,7 @@ static void face_hide_update(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { TLS &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span faces = bke::pbvh::node_faces(nodes[i]); + const Span faces = nodes[i].faces(); tls.new_hide.resize(faces.size()); MutableSpan new_hide = tls.new_hide; @@ -1364,7 +1364,7 @@ static void edit_fairing(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.translations.resize(verts.size()); const MutableSpan translations = tls.translations; for (const int i : verts.index_range()) { @@ -1654,7 +1654,7 @@ static void gesture_apply_mesh(gesture::GestureData &gesture_data, const IndexMa node_mask.foreach_index(GrainSize(1), [&](const int i) { undo::push_node(depsgraph, *gesture_data.vc.obact, &nodes[i], undo::Type::FaceSet); bool any_updated = false; - for (const int face : bke::pbvh::node_faces(nodes[i])) { + for (const int face : nodes[i].faces()) { if (!hide_poly.is_empty() && hide_poly[face]) { continue; } diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc index 0e64933d173..3c6c9945004 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.cc @@ -112,7 +112,7 @@ static void color_filter_task(const Depsgraph &depsgraph, const Span orig_colors = orig_color_data_get_mesh(ob, node); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -325,7 +325,7 @@ static void sculpt_color_presmooth_init(const Mesh &mesh, SculptSession &ss) const MutableSpan pre_smoothed_color = ss.filter_cache->pre_smoothed_color; node_mask.foreach_index(GrainSize(1), [&](const int i) { - for (const int vert : bke::pbvh::node_unique_verts(nodes[i])) { + for (const int vert : nodes[i].verts()) { pre_smoothed_color[vert] = color_vert_get( faces, corner_verts, vert_to_face_map, colors, color_attribute.domain, vert); } @@ -340,7 +340,7 @@ static void sculpt_color_presmooth_init(const Mesh &mesh, SculptSession &ss) threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.vert_neighbors.resize(verts.size()); calc_vert_neighbors(faces, corner_verts, vert_to_face_map, {}, verts, tls.vert_neighbors); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc index 1f61097390a..0f092076911 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mask.cc @@ -138,7 +138,7 @@ static void smooth_mask_mesh(const OffsetIndices faces, FilterLocalData &tls, MutableSpan new_mask) { - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.vert_neighbors.resize(verts.size()); const MutableSpan> neighbors = tls.vert_neighbors; @@ -156,7 +156,7 @@ static void sharpen_mask_mesh(const OffsetIndices faces, FilterLocalData &tls, MutableSpan new_mask) { - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.node_mask.resize(verts.size()); const MutableSpan node_mask = tls.node_mask; @@ -180,7 +180,7 @@ static void grow_mask_mesh(const OffsetIndices faces, FilterLocalData &tls, MutableSpan new_mask) { - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.vert_neighbors.resize(verts.size()); const MutableSpan> neighbors = tls.vert_neighbors; @@ -203,7 +203,7 @@ static void shrink_mask_mesh(const OffsetIndices faces, FilterLocalData &tls, MutableSpan new_mask) { - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.vert_neighbors.resize(verts.size()); const MutableSpan> neighbors = tls.vert_neighbors; @@ -296,7 +296,7 @@ static void apply_new_mask_grids(const Depsgraph &depsgraph, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); node_mask.foreach_index(GrainSize(1), [&](const int i, const int pos) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span new_node_mask = new_mask.slice(node_verts[pos]); if (mask_equals_array_grids(subdiv_ccg.grids, key, grids, new_node_mask)) { return; @@ -314,8 +314,8 @@ static void smooth_mask_grids(const SubdivCCG &subdiv_ccg, const bke::pbvh::GridsNode &node, MutableSpan new_mask) { - const Span grids = bke::pbvh::node_grid_indices(node); - average_neighbor_mask_grids(subdiv_ccg, bke::pbvh::node_grid_indices(node), new_mask); + const Span grids = node.grids(); + average_neighbor_mask_grids(subdiv_ccg, node.grids(), new_mask); copy_old_hidden_mask_grids(subdiv_ccg, grids, new_mask); } @@ -326,7 +326,7 @@ static void sharpen_mask_grids(const SubdivCCG &subdiv_ccg, { const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.node_mask.resize(grid_verts_num); @@ -347,7 +347,7 @@ static void grow_mask_grids(const SubdivCCG &subdiv_ccg, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); const Span elems = subdiv_ccg.grids; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); for (const int i : grids.index_range()) { const int grid = grids[i]; @@ -382,7 +382,7 @@ static void shrink_mask_grids(const SubdivCCG &subdiv_ccg, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); const Span elems = subdiv_ccg.grids; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); for (const int i : grids.index_range()) { const int grid = grids[i]; @@ -419,7 +419,7 @@ static void increase_contrast_mask_grids(const Depsgraph &depsgraph, SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.node_mask.resize(grid_verts_num); @@ -450,7 +450,7 @@ static void decrease_contrast_mask_grids(const Depsgraph &depsgraph, SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.node_mask.resize(grid_verts_num); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc index 44854dce299..e47d9e51474 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc @@ -359,7 +359,7 @@ static void calc_smooth_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const Span positions = gather_data_mesh(positions_eval, verts, tls.positions); const OrigPositionData orig_data = orig_position_data_get_mesh(object, nodes[i]); @@ -411,7 +411,7 @@ static void calc_smooth_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); @@ -507,7 +507,7 @@ static void calc_inflate_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const Span positions = gather_data_mesh(positions_eval, verts, tls.positions); const OrigPositionData orig_data = orig_position_data_get_mesh(object, nodes[i]); @@ -540,7 +540,7 @@ static void calc_inflate_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); @@ -626,7 +626,7 @@ static void calc_scale_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const Span positions = gather_data_mesh(positions_eval, verts, tls.positions); const OrigPositionData orig_data = orig_position_data_get_mesh(object, nodes[i]); @@ -659,7 +659,7 @@ static void calc_scale_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); @@ -761,7 +761,7 @@ static void calc_sphere_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const Span positions = gather_data_mesh(positions_eval, verts, tls.positions); const OrigPositionData orig_data = orig_position_data_get_mesh(object, nodes[i]); @@ -793,7 +793,7 @@ static void calc_sphere_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); @@ -888,7 +888,7 @@ static void calc_random_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const Span positions = gather_data_mesh(positions_eval, verts, tls.positions); const OrigPositionData orig_data = orig_position_data_get_mesh(object, nodes[i]); @@ -922,7 +922,7 @@ static void calc_random_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); @@ -1017,7 +1017,7 @@ static void calc_relax_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -1069,7 +1069,7 @@ static void calc_relax_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); @@ -1181,7 +1181,7 @@ static void calc_relax_face_sets_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -1236,7 +1236,7 @@ static void calc_relax_face_sets_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); @@ -1353,7 +1353,7 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const Span positions = gather_data_mesh(positions_eval, verts, tls.positions); const OrigPositionData orig_data = orig_position_data_get_mesh(object, nodes[i]); @@ -1398,7 +1398,7 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -1442,7 +1442,7 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); @@ -1482,7 +1482,7 @@ static void calc_surface_smooth_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); tls.factors.resize(orig_data.positions.size()); @@ -1648,7 +1648,7 @@ static void calc_sharpen_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int node_index) { - const Span verts = bke::pbvh::node_unique_verts(nodes[node_index]); + const Span verts = nodes[node_index].verts(); const Span positions = gather_data_mesh(positions_eval, verts, tls.positions); tls.factors.resize(verts.size()); @@ -1724,7 +1724,7 @@ static void calc_sharpen_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int node_index) { - const Span grids = bke::pbvh::node_grid_indices(nodes[node_index]); + const Span grids = nodes[node_index].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.factors.resize(positions.size()); @@ -1905,7 +1905,7 @@ static void calc_enhance_details_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); const Span positions = gather_data_mesh(positions_eval, verts, tls.positions); const OrigPositionData orig_data = orig_position_data_get_mesh(object, nodes[i]); @@ -1937,7 +1937,7 @@ static void calc_enhance_details_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); @@ -2017,7 +2017,7 @@ static void calc_erase_displacement_filter(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, nodes[i]); @@ -2132,7 +2132,7 @@ static void mesh_filter_sharpen_init(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.vert_neighbors.resize(verts.size()); const MutableSpan> neighbors = tls.vert_neighbors; @@ -2158,7 +2158,7 @@ static void mesh_filter_sharpen_init(const Depsgraph &depsgraph, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.smooth_directions.resize(grid_verts_num); diff --git a/source/blender/editors/sculpt_paint/sculpt_hide.cc b/source/blender/editors/sculpt_paint/sculpt_hide.cc index efac466e7fc..93c903f36e1 100644 --- a/source/blender/editors/sculpt_paint/sculpt_hide.cc +++ b/source/blender/editors/sculpt_paint/sculpt_hide.cc @@ -25,7 +25,7 @@ Span node_visible_verts(const bke::pbvh::MeshNode &node, if (BKE_pbvh_node_fully_hidden_get(node)) { return {}; } - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); if (hide_vert.is_empty()) { return verts; } diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc index 22b535a5ebc..e36c23fc122 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_init.cc +++ b/source/blender/editors/sculpt_paint/sculpt_mask_init.cc @@ -96,7 +96,7 @@ static void init_mask_grids(Main &bmain, undo::push_nodes(depsgraph, object, node_mask, undo::Type::Mask); node_mask.foreach_index(GrainSize(1), [&](const int i) { - for (const int grid : bke::pbvh::node_grid_indices(nodes[i])) { + for (const int grid : nodes[i].grids()) { write_fn(grid_hidden, grid, grids[grid]); } BKE_pbvh_node_mark_update_mask(nodes[i]); diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.cc b/source/blender/editors/sculpt_paint/sculpt_ops.cc index ff07d850439..bcdb465398e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.cc +++ b/source/blender/editors/sculpt_paint/sculpt_ops.cc @@ -974,7 +974,7 @@ static void bake_mask_mesh(const Depsgraph &depsgraph, const MutableSpan mask) { const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -1008,7 +1008,7 @@ static void bake_mask_grids(const Depsgraph &depsgraph, SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; tls.factors.resize(grid_verts_num); diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc index 4cb74507133..17816c3915e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.cc +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.cc @@ -274,7 +274,7 @@ static void do_color_smooth_task(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -359,7 +359,7 @@ static void do_paint_brush_task(const Depsgraph &depsgraph, const float bstrength = fabsf(ss.cache->bstrength); const float alpha = BKE_brush_alpha_get(ss.scene, &brush); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -499,7 +499,7 @@ static void do_sample_wet_paint_task(const Object &object, const SculptSession &ss = *object.sculpt; const float radius = ss.cache->radius * brush.wet_paint_radius_factor; - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -689,7 +689,7 @@ static void do_smear_brush_task(const Depsgraph &depsgraph, const Mesh &mesh = *static_cast(object.data); const float strength = ss.cache->bstrength; - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); tls.factors.resize(verts.size()); const MutableSpan factors = tls.factors; @@ -894,7 +894,7 @@ void do_smear_brush(const Depsgraph &depsgraph, else { /* Smear mode. */ node_mask.foreach_index(GrainSize(1), [&](const int i) { - for (const int vert : bke::pbvh::node_unique_verts(nodes[i])) { + for (const int vert : nodes[i].verts()) { ss.cache->paint_brush.prev_colors[vert] = color_vert_get(faces, corner_verts, vert_to_face_map, diff --git a/source/blender/editors/sculpt_paint/sculpt_pose.cc b/source/blender/editors/sculpt_paint/sculpt_pose.cc index 4f9f678c8cc..8b43fd49b5c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_pose.cc +++ b/source/blender/editors/sculpt_paint/sculpt_pose.cc @@ -167,7 +167,7 @@ static void calc_mesh(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const Span positions = gather_data_mesh(positions_eval, verts, tls.positions); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); @@ -218,7 +218,7 @@ static void calc_grids(const Depsgraph &depsgraph, const StrokeCache &cache = *ss.cache; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const Span positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); const OrigPositionData orig_data = orig_position_data_get_grids(object, node); @@ -396,7 +396,7 @@ static void grow_factors_grids(const ePaintSymmetryFlags symm, const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); const Span elems = subdiv_ccg.grids; const BitGroupVector<> &grid_hidden = subdiv_ccg.grid_hidden; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); for (const int i : grids.index_range()) { const int grid = grids[i]; diff --git a/source/blender/editors/sculpt_paint/sculpt_project.cc b/source/blender/editors/sculpt_paint/sculpt_project.cc index 37e94b2578f..fb3e3cb51ec 100644 --- a/source/blender/editors/sculpt_paint/sculpt_project.cc +++ b/source/blender/editors/sculpt_paint/sculpt_project.cc @@ -55,7 +55,7 @@ static void apply_projection_mesh(const Depsgraph &depsgraph, { Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); const MutableSpan normals = gather_data_mesh(vert_normals, verts, tls.normals); @@ -83,7 +83,7 @@ static void apply_projection_grids(const Sculpt &sd, SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); tls.normals.resize(positions.size()); diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.cc b/source/blender/editors/sculpt_paint/sculpt_smooth.cc index 90f13dd495e..ad5cd75b61e 100644 --- a/source/blender/editors/sculpt_paint/sculpt_smooth.cc +++ b/source/blender/editors/sculpt_paint/sculpt_smooth.cc @@ -785,7 +785,7 @@ void blur_geometry_data_array(const Object &object, threading::parallel_for(node_mask.index_range(), 1, [&](const IndexRange range) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int node_index) { - const Span grids = bke::pbvh::node_grid_indices(nodes[node_index]); + const Span grids = nodes[node_index].grids(); const int grid_verts_num = key.grid_area * grids.size(); tls.new_factors.resize(grid_verts_num); diff --git a/source/blender/editors/sculpt_paint/sculpt_transform.cc b/source/blender/editors/sculpt_paint/sculpt_transform.cc index 1316ea84c85..213d3aa4d10 100644 --- a/source/blender/editors/sculpt_paint/sculpt_transform.cc +++ b/source/blender/editors/sculpt_paint/sculpt_transform.cc @@ -199,7 +199,7 @@ static void transform_node_mesh(const Depsgraph &depsgraph, { const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const OrigPositionData orig_data = orig_position_data_get_mesh(object, node); tls.factors.resize(verts.size()); @@ -227,7 +227,7 @@ static void transform_node_grids(const Sculpt &sd, SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; const CCGKey key = BKE_subdiv_ccg_key_top_level(subdiv_ccg); - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const int grid_verts_num = grids.size() * key.grid_area; const OrigPositionData orig_data = orig_position_data_get_grids(object, node); @@ -371,7 +371,7 @@ static void elastic_transform_node_mesh(const Depsgraph &depsgraph, { const Mesh &mesh = *static_cast(object.data); - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); const MutableSpan positions = gather_data_mesh(positions_eval, verts, tls.positions); /* TODO: Using the factors array is unnecessary when there are no hidden vertices and no mask. */ @@ -401,7 +401,7 @@ static void elastic_transform_node_grids(const Sculpt &sd, SculptSession &ss = *object.sculpt; SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - const Span grids = bke::pbvh::node_grid_indices(node); + const Span grids = node.grids(); const MutableSpan positions = gather_grids_positions(subdiv_ccg, grids, tls.positions); /* TODO: Using the factors array is unnecessary when there are no hidden vertices and no mask. */ @@ -690,7 +690,7 @@ static float3 average_unmasked_position(const Depsgraph &depsgraph, LocalData &tls = all_tls.local(); threading::isolate_task([&]() { node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); tls.positions.resize(verts.size()); const MutableSpan positions = tls.positions; @@ -719,7 +719,7 @@ static float3 average_unmasked_position(const Depsgraph &depsgraph, [&](const IndexRange range, AveragePositionAccumulation sum) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const MutableSpan positions = gather_grids_positions( subdiv_ccg, grids, tls.positions); @@ -812,7 +812,7 @@ static float3 average_mask_border_position(const Depsgraph &depsgraph, [&](const IndexRange range, AveragePositionAccumulation sum) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span verts = bke::pbvh::node_unique_verts(nodes[i]); + const Span verts = nodes[i].verts(); MutableSpan positions = gather_data_mesh(vert_positions, verts, tls.positions); MutableSpan masks = gather_data_mesh(mask_attr, verts, tls.masks); @@ -840,7 +840,7 @@ static float3 average_mask_border_position(const Depsgraph &depsgraph, [&](const IndexRange range, AveragePositionAccumulation sum) { LocalData &tls = all_tls.local(); node_mask.slice(range).foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); const MutableSpan positions = gather_grids_positions( subdiv_ccg, grids, tls.positions); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index aca227d4b7d..d6a23a186f8 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -1007,7 +1007,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) restore_position_grids(grids, key, *unode, modified_grids); } node_mask.foreach_index([&](const int i) { - const Span grids = bke::pbvh::node_grid_indices(nodes[i]); + const Span grids = nodes[i].grids(); if (indices_contain_true(modified_grids, grids)) { BKE_pbvh_node_mark_positions_update(nodes[i]); } @@ -1022,7 +1022,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) Array modified_verts(ss.totvert, false); restore_position_mesh(object, step_data.nodes, modified_verts); node_mask.foreach_index([&](const int i) { - if (indices_contain_true(modified_verts, bke::pbvh::node_verts(nodes[i]))) { + if (indices_contain_true(modified_verts, nodes[i].all_verts())) { BKE_pbvh_node_mark_positions_update(nodes[i]); } }); @@ -1054,7 +1054,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) restore_vert_visibility_grids(subdiv_ccg, *unode, modified_grids); } node_mask.foreach_index([&](const int i) { - if (indices_contain_true(modified_grids, bke::pbvh::node_grid_indices(nodes[i]))) { + if (indices_contain_true(modified_grids, nodes[i].grids())) { BKE_pbvh_node_mark_update_visibility(nodes[i]); } }); @@ -1066,7 +1066,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) restore_vert_visibility_mesh(object, *unode, modified_verts); } node_mask.foreach_index([&](const int i) { - if (indices_contain_true(modified_verts, bke::pbvh::node_verts(nodes[i]))) { + if (indices_contain_true(modified_verts, nodes[i].all_verts())) { BKE_pbvh_node_mark_update_visibility(nodes[i]); } }); @@ -1109,7 +1109,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) else { MutableSpan nodes = ss.pbvh->nodes(); node_mask.foreach_index([&](const int i) { - const Span faces = bke::pbvh::node_faces(nodes[i]); + const Span faces = nodes[i].faces(); if (indices_contain_true(modified_faces, faces)) { BKE_pbvh_node_mark_update_visibility(nodes[i]); } @@ -1136,7 +1136,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) restore_mask_grids(object, *unode, modified_grids); } node_mask.foreach_index([&](const int i) { - if (indices_contain_true(modified_grids, bke::pbvh::node_grid_indices(nodes[i]))) { + if (indices_contain_true(modified_grids, nodes[i].grids())) { BKE_pbvh_node_mark_update_mask(nodes[i]); } }); @@ -1148,7 +1148,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) restore_mask_mesh(object, *unode, modified_verts); } node_mask.foreach_index([&](const int i) { - if (indices_contain_true(modified_verts, bke::pbvh::node_verts(nodes[i]))) { + if (indices_contain_true(modified_verts, nodes[i].all_verts())) { BKE_pbvh_node_mark_update_mask(nodes[i]); } }); @@ -1186,7 +1186,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) else { MutableSpan nodes = ss.pbvh->nodes(); node_mask.foreach_index([&](const int i) { - const Span faces = bke::pbvh::node_faces(nodes[i]); + const Span faces = nodes[i].faces(); if (indices_contain_true(modified_faces, faces)) { BKE_pbvh_node_mark_update_face_sets(nodes[i]); } @@ -1207,7 +1207,7 @@ static void restore_list(bContext *C, Depsgraph *depsgraph, StepData &step_data) Array modified_verts(ss.totvert, false); restore_color(object, step_data, modified_verts); node_mask.foreach_index([&](const int i) { - if (indices_contain_true(modified_verts, bke::pbvh::node_verts(nodes[i]))) { + if (indices_contain_true(modified_verts, nodes[i].all_verts())) { BKE_pbvh_node_mark_update_color(nodes[i]); } }); @@ -1280,7 +1280,7 @@ static void store_vert_visibility_grids(const SubdivCCG &subdiv_ccg, return; } - const Span grid_indices = bke::pbvh::node_grid_indices(node); + const Span grid_indices = node.grids(); unode.grid_hidden = BitGroupVector<0>(grid_indices.size(), grid_hidden.group_size()); for (const int i : grid_indices.index_range()) { unode.grid_hidden[i].copy_from(grid_hidden[grid_indices[i]]); @@ -1343,7 +1343,7 @@ static void store_vert_visibility_mesh(const Mesh &mesh, const bke::pbvh::Node & return; } - const Span verts = bke::pbvh::node_verts(static_cast(node)); + const Span verts = static_cast(node).all_verts(); for (const int i : verts.index_range()) { unode.vert_hidden[i].set(hide_vert[verts[i]]); } @@ -1403,13 +1403,13 @@ static void store_color(const Mesh &mesh, const bke::pbvh::MeshNode &node, Node /* NOTE: even with loop colors we still store (derived) * vertex colors for original data lookup. */ - const Span verts = bke::pbvh::node_unique_verts(node); + const Span verts = node.verts(); unode.col.reinitialize(verts.size()); color::gather_colors_vert( faces, corner_verts, vert_to_face_map, colors, color_attribute.domain, verts, unode.col); if (color_attribute.domain == bke::AttrDomain::Corner) { - for (const int face : bke::pbvh::node_faces(node)) { + for (const int face : node.faces()) { for (const int corner : faces[face]) { unode.corner_indices.append(corner); } @@ -1460,14 +1460,14 @@ static void fill_node_data_mesh(const Depsgraph &depsgraph, const SculptSession &ss = *object.sculpt; const Mesh &mesh = *static_cast(object.data); - unode.vert_indices = bke::pbvh::node_verts(node); - unode.unique_verts_num = bke::pbvh::node_unique_verts(node).size(); + unode.vert_indices = node.all_verts(); + unode.unique_verts_num = node.verts().size(); const int verts_num = unode.vert_indices.size(); const bool need_faces = ELEM(type, Type::FaceSet, Type::HideFace); if (need_faces) { - unode.face_indices = bke::pbvh::node_faces(node); + unode.face_indices = node.faces(); } switch (type) { @@ -1530,7 +1530,7 @@ static void fill_node_data_grids(const Object &object, const Mesh &base_mesh = *static_cast(object.data); const SubdivCCG &subdiv_ccg = *ss.subdiv_ccg; - unode.grids = bke::pbvh::node_grid_indices(node); + unode.grids = node.grids(); const int grid_area = subdiv_ccg.grid_size * subdiv_ccg.grid_size; const int verts_num = unode.grids.size() * grid_area; -- 2.30.2