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
This commit is contained in:
parent
60fbed3dba
commit
9743a58f7d
Notes:
blender-bot
2023-04-04 07:45:26 +02:00
Referenced by issue #81618, Hidden mesh will appear visible Referenced by issue #81403, Certain parts of a mesh parented to an armature in edit mode cannot be edited at all. Referenced by issue #80771, Mode switching hides vertices in Edit mode (Weight paint / Sculpt mode --> Edit mode)
|
@ -1832,18 +1832,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)
|
||||
|
|
Loading…
Reference in New Issue