[Bf-blender-cvs] [9743a58f7d1] blender-v2.90-release: Fix T80771: Avoid changing the visibility of loose geometry when entering Sculpt Mode

Pablo Dobarro noreply at git.blender.org
Mon Sep 21 11:19:06 CEST 2020


Commit: 9743a58f7d1f0fe8b5460a13b64bee05f66e6db6
Author: Pablo Dobarro
Date:   Thu Sep 17 23:51:01 2020 +0200
Branches: blender-v2.90-release
https://developer.blender.org/rB9743a58f7d1f0fe8b5460a13b64bee05f66e6db6

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

===================================================================

M	source/blender/blenkernel/intern/paint.c

===================================================================

diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 0ba5ec43318..bdead81d97d 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -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)



More information about the Bf-blender-cvs mailing list