From 1e3dc838d92b5a74ec1cd1eb8d7da45530454544 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Sat, 29 Jun 2024 18:45:23 -0400 Subject: [PATCH] Cleanup: Sculpt: Use accessors for PBVH node vertex indices Makes it easier to search for where these are used (and whether it's the unique or shared vertices being accessed). --- source/blender/blenkernel/intern/pbvh.cc | 25 ++++++++----------- .../editors/sculpt_paint/sculpt_boundary.cc | 1 - 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 86e868ea7a8..f99769a97db 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -1145,10 +1145,8 @@ static void calc_node_vert_normals(const GroupedSpan vert_to_face_map, { threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) { for (const PBVHNode *node : nodes.slice(range)) { - normals_calc_verts_simple(vert_to_face_map, - face_normals, - node->vert_indices.as_span().take_front(node->uniq_verts), - vert_normals); + normals_calc_verts_simple( + vert_to_face_map, face_normals, node_unique_verts(*node), vert_normals); } }); } @@ -1251,7 +1249,7 @@ void update_normals(PBVH &pbvh, SubdivCCG *subdiv_ccg) void update_node_bounds_mesh(const Span positions, PBVHNode &node) { Bounds bounds = negative_bounds(); - for (const int vert : node.vert_indices) { + for (const int vert : node_verts(node)) { math::min_max(positions[vert], bounds.min, bounds.max); } node.bounds = bounds; @@ -1350,12 +1348,11 @@ void store_bounds_orig(PBVH &pbvh) void node_update_mask_mesh(const Span mask, PBVHNode &node) { - const bool fully_masked = std::all_of(node.vert_indices.begin(), - node.vert_indices.end(), - [&](const int vert) { return mask[vert] == 1.0f; }); - const bool fully_unmasked = std::all_of(node.vert_indices.begin(), - node.vert_indices.end(), - [&](const int vert) { return mask[vert] <= 0.0f; }); + const Span verts = node_verts(node); + 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( + verts.begin(), verts.end(), [&](const int vert) { return mask[vert] <= 0.0f; }); SET_FLAG_FROM_TEST(node.flag, fully_masked, PBVH_FullyMasked); SET_FLAG_FROM_TEST(node.flag, fully_unmasked, PBVH_FullyUnmasked); node.flag &= ~PBVH_UpdateMask; @@ -1476,9 +1473,9 @@ void update_mask(PBVH &pbvh) void node_update_visibility_mesh(const Span hide_vert, PBVHNode &node) { BLI_assert(!hide_vert.is_empty()); - const bool fully_hidden = std::all_of(node.vert_indices.begin(), - node.vert_indices.end(), - [&](const int vert) { return hide_vert[vert]; }); + const Span verts = node_verts(node); + 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); node.flag &= ~PBVH_UpdateVisibility; } diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.cc b/source/blender/editors/sculpt_paint/sculpt_boundary.cc index 29068e3d945..0985e257947 100644 --- a/source/blender/editors/sculpt_paint/sculpt_boundary.cc +++ b/source/blender/editors/sculpt_paint/sculpt_boundary.cc @@ -133,7 +133,6 @@ static void add_index(SculptBoundary &boundary, */ static bool is_vert_in_editable_boundary(SculptSession &ss, const PBVHVertRef initial_vert) { - if (!hide::vert_visible_get(ss, initial_vert)) { return false; }