diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-09-18 00:51:01 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-09-18 00:51:21 +0300 |
commit | cacd57b67a15e08bce3b1c9a136004516c593672 (patch) | |
tree | 5d726d373975b01be1d99008603f00230a6d9816 | |
parent | adfbb77b20c2c0f55c8bd99313ae11e546687d83 (diff) |
Fix T80771: Avoid changing the visibility of loose geometry when entering Sculpt Mode
When entering scultp mode the visibility from the Face Sets is copied to
the base mesh. This steps was considering that if a vertex belongs to a
face with a visibible Face Set ID, it should be visible. As loose
geometry may not have any faces, those vertex were set to hidden.
Now this function check if a vertex visibility should be modified by the
face sets (by checking the loops), avoiding modifying the visibility of
loose geometry unintentionally.
Reviewed By: sergey
Maniphest Tasks: T80771
Differential Revision: https://developer.blender.org/D8899
-rw-r--r-- | source/blender/blenkernel/intern/paint.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c index 545d1bdee13..57e7fb0eb62 100644 --- a/source/blender/blenkernel/intern/paint.c +++ b/source/blender/blenkernel/intern/paint.c @@ -1885,18 +1885,31 @@ static void sculpt_sync_face_sets_visibility_to_base_mesh(Mesh *mesh) return; } - for (int i = 0; i < mesh->totvert; i++) { - mesh->mvert[i].flag |= ME_HIDE; - } + /* Enabled if the vertex should be visible according to the Face Sets. */ + BLI_bitmap *visibile_vertex = BLI_BITMAP_NEW(mesh->totvert, "visible vertices"); + /* Enabled if the visibility of this vertex can be affected by the Face Sets to avoid modifying + * disconnected geometry. */ + BLI_bitmap *modified_vertex = BLI_BITMAP_NEW(mesh->totvert, "modified vertices"); for (int i = 0; i < mesh->totpoly; i++) { - if (face_sets[i] >= 0) { - for (int l = 0; l < mesh->mpoly[i].totloop; l++) { - MLoop *loop = &mesh->mloop[mesh->mpoly[i].loopstart + l]; - mesh->mvert[loop->v].flag &= ~ME_HIDE; + const bool is_face_set_visible = face_sets[i] >= 0; + for (int l = 0; l < mesh->mpoly[i].totloop; l++) { + MLoop *loop = &mesh->mloop[mesh->mpoly[i].loopstart + l]; + if (is_face_set_visible) { + BLI_BITMAP_ENABLE(visibile_vertex, loop->v); } + BLI_BITMAP_ENABLE(modified_vertex, loop->v); } } + + for (int i = 0; i < mesh->totvert; i++) { + if (BLI_BITMAP_TEST(modified_vertex, i) && !BLI_BITMAP_TEST(visibile_vertex, i)) { + mesh->mvert[i].flag |= ME_HIDE; + } + } + + MEM_SAFE_FREE(visibile_vertex); + MEM_SAFE_FREE(modified_vertex); } static void sculpt_sync_face_sets_visibility_to_grids(Mesh *mesh, SubdivCCG *subdiv_ccg) |