Cleanup: Sculpt explicitly retrieve mesh face visibility attribute

Rather than relying on the pointers in `SculptSession` which should be
removed eventually, to avoid redundant state storage.
This commit is contained in:
Hans Goudey
2023-12-08 10:36:22 -05:00
parent 0137e5494a
commit 83810e28fc
2 changed files with 10 additions and 3 deletions

View File

@@ -276,11 +276,12 @@ static bool sculpt_expand_state_get(SculptSession *ss,
* Returns true when the target data should be modified by expand.
*/
static bool sculpt_expand_face_state_get(SculptSession *ss,
const Span<bool> hide_poly,
const Span<int> face_sets,
ExpandCache *expand_cache,
const int f)
{
if (ss->hide_poly && ss->hide_poly[f]) {
if (!hide_poly.is_empty() && hide_poly[f]) {
return false;
}
@@ -1357,9 +1358,12 @@ static void sculpt_expand_face_sets_update(Object &object, ExpandCache *expand_c
using namespace blender;
using namespace blender::ed::sculpt_paint;
bke::SpanAttributeWriter<int> face_sets = face_set::ensure_face_sets_mesh(object);
Mesh &mesh = *static_cast<Mesh *>(object.data);
const bke::AttributeAccessor attributes = mesh.attributes();
const VArraySpan<bool> hide_poly = *attributes.lookup<bool>(".hide_poly", ATTR_DOMAIN_FACE);
for (const int f : face_sets.span.index_range()) {
const bool enabled = sculpt_expand_face_state_get(
object.sculpt, face_sets.span, expand_cache, f);
object.sculpt, hide_poly, face_sets.span, expand_cache, f);
if (!enabled) {
continue;
}

View File

@@ -78,6 +78,7 @@ static bool sculpt_geodesic_mesh_test_dist_add(blender::Span<blender::float3> ve
static float *geodesic_mesh_create(Object *ob, GSet *initial_verts, const float limit_radius)
{
using namespace blender;
SculptSession *ss = ob->sculpt;
Mesh *mesh = BKE_object_get_original_mesh(ob);
@@ -91,6 +92,8 @@ static float *geodesic_mesh_create(Object *ob, GSet *initial_verts, const float
const blender::OffsetIndices faces = mesh->faces();
const blender::Span<int> corner_verts = mesh->corner_verts();
const blender::Span<int> corner_edges = mesh->corner_edges();
const bke::AttributeAccessor attributes = mesh->attributes();
const VArraySpan<bool> hide_poly = *attributes.lookup<bool>(".hide_poly", ATTR_DOMAIN_FACE);
float *dists = static_cast<float *>(MEM_malloc_arrayN(totvert, sizeof(float), __func__));
BLI_bitmap *edge_tag = BLI_BITMAP_NEW(totedge, "edge tag");
@@ -174,7 +177,7 @@ static float *geodesic_mesh_create(Object *ob, GSet *initial_verts, const float
if (ss->epmap[e].size() != 0) {
for (int face_map_index = 0; face_map_index < ss->epmap[e].size(); face_map_index++) {
const int face = ss->epmap[e][face_map_index];
if (ss->hide_poly && ss->hide_poly[face]) {
if (!hide_poly.is_empty() && hide_poly[face]) {
continue;
}
for (const int v_other : corner_verts.slice(faces[face])) {