Cleanup: Sculpt: Remove unnecessary absolute values of face sets #109612

Merged
Hans Goudey merged 1 commits from HooglyBoogly/blender:cleanup-sculpt-face-set-abs-remove into main 2023-07-02 16:21:37 +02:00
5 changed files with 13 additions and 24 deletions

View File

@ -273,8 +273,8 @@ static void geometry_extract_tag_face_set(BMesh *bm, GeometryExtractParams *para
BMFace *f;
BMIter iter;
BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
const int face_set_id = abs(BM_ELEM_CD_GET_INT(f, cd_face_sets_offset));
BM_elem_flag_set(f, BM_ELEM_TAG, face_set_id != tag_face_set_id);
const int face_set = BM_ELEM_CD_GET_INT(f, cd_face_sets_offset);
BM_elem_flag_set(f, BM_ELEM_TAG, face_set != tag_face_set_id);
}
}

View File

@ -591,7 +591,7 @@ int SCULPT_vertex_face_set_get(SculptSession *ss, PBVHVertRef vertex)
int face_set = 0;
for (const int poly_index : ss->pmap[vertex.i]) {
if (ss->face_sets[poly_index] > face_set) {
face_set = abs(ss->face_sets[poly_index]);
face_set = ss->face_sets[poly_index];
}
}
return face_set;
@ -737,7 +737,7 @@ static bool sculpt_check_unique_face_set_for_edge_in_base_mesh(SculptSession *ss
}
if (p1 != -1 && p2 != -1) {
return abs(ss->face_sets[p1]) == (ss->face_sets[p2]);
return ss->face_sets[p1] == ss->face_sets[p2];
}
return true;
}

View File

@ -2055,17 +2055,6 @@ static void sculpt_expand_delete_face_set_id(int *r_face_sets,
BLI_LINKSTACK_FREE(queue);
BLI_LINKSTACK_FREE(queue_next);
/* Ensure that the visibility state of the modified Face Sets is the same as the original ones.
*/
for (int i = 0; i < totface; i++) {
if (expand_cache->original_face_sets[i] >= 0) {
r_face_sets[i] = abs(r_face_sets[i]);
}
else {
r_face_sets[i] = -abs(r_face_sets[i]);
}
}
}
static void sculpt_expand_cache_initial_config_set(bContext *C,

View File

@ -1069,7 +1069,7 @@ static void sculpt_face_set_grow(Object *ob,
if (neighbor_face_index == p) {
continue;
}
if (abs(prev_face_sets[neighbor_face_index]) == active_face_set_id) {
if (prev_face_sets[neighbor_face_index] == active_face_set_id) {
ss->face_sets[p] = active_face_set_id;
}
}
@ -1091,13 +1091,13 @@ static void sculpt_face_set_shrink(Object *ob,
if (!modify_hidden && prev_face_sets[p] <= 0) {
continue;
}
if (abs(prev_face_sets[p]) == active_face_set_id) {
if (prev_face_sets[p] == active_face_set_id) {
for (const int vert_i : corner_verts.slice(polys[p])) {
for (const int neighbor_face_index : ss->pmap[vert_i]) {
if (neighbor_face_index == p) {
continue;
}
if (abs(prev_face_sets[neighbor_face_index]) != active_face_set_id) {
if (prev_face_sets[neighbor_face_index] != active_face_set_id) {
ss->face_sets[p] = prev_face_sets[neighbor_face_index];
}
}
@ -1297,7 +1297,7 @@ static void sculpt_face_set_edit_modify_geometry(bContext *C,
{
Mesh *mesh = static_cast<Mesh *>(ob->data);
ED_sculpt_undo_geometry_begin(ob, op);
sculpt_face_set_apply_edit(ob, abs(active_face_set), mode, modify_hidden);
sculpt_face_set_apply_edit(ob, active_face_set, mode, modify_hidden);
ED_sculpt_undo_geometry_end(ob);
BKE_mesh_batch_cache_dirty_tag(mesh, BKE_MESH_BATCH_DIRTY_ALL);
DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY);
@ -1340,7 +1340,7 @@ static void sculpt_face_set_edit_modify_face_sets(Object *ob,
for (PBVHNode *node : nodes) {
SCULPT_undo_push_node(ob, node, SCULPT_UNDO_FACE_SETS);
}
sculpt_face_set_apply_edit(ob, abs(active_face_set), mode, modify_hidden);
sculpt_face_set_apply_edit(ob, active_face_set, mode, modify_hidden);
SCULPT_undo_push_end(ob);
face_set_edit_do_post_visibility_updates(ob, nodes);
}
@ -1364,7 +1364,7 @@ static void sculpt_face_set_edit_modify_coordinates(bContext *C,
BKE_pbvh_node_mark_update(node);
SCULPT_undo_push_node(ob, node, SCULPT_UNDO_COORDS);
}
sculpt_face_set_apply_edit(ob, abs(active_face_set), mode, false, strength);
sculpt_face_set_apply_edit(ob, active_face_set, mode, false, strength);
if (ss->deform_modifiers_active || ss->shapekey_active) {
SCULPT_flush_stroke_deform(sd, ob, true);

View File

@ -207,9 +207,9 @@ static void gather_vert_attributes(const Mesh &mesh_src,
const IndexMask &vert_mask,
Mesh &mesh_dst)
{
Set<std::string> names;
Set<std::string> vertex_group_names;
LISTBASE_FOREACH (bDeformGroup *, group, &mesh_src.vertex_group_names) {
names.add(group->name);
vertex_group_names.add(group->name);
}
const Span<MDeformVert> src = mesh_src.deform_verts();
@ -229,7 +229,7 @@ static void gather_vert_attributes(const Mesh &mesh_src,
bke::gather_attributes(mesh_src.attributes(),
ATTR_DOMAIN_POINT,
propagation_info,
names,
vertex_group_names,
vert_mask,
mesh_dst.attributes_for_write());
});