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).
This commit is contained in:
Hans Goudey 2024-06-29 18:45:23 -04:00
parent 2e36675dec
commit 1e3dc838d9
2 changed files with 11 additions and 15 deletions

@ -1145,10 +1145,8 @@ static void calc_node_vert_normals(const GroupedSpan<int> 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<float3> positions, PBVHNode &node)
{
Bounds<float3> 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<float> 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<int> 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<bool> 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<int> 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;
}

@ -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;
}