[Bf-blender-cvs] [cacd57b67a1] master: Fix T80771: Avoid changing the visibility of loose geometry when entering Sculpt Mode

Pablo Dobarro noreply at git.blender.org
Thu Sep 17 23:52:00 CEST 2020


Commit: cacd57b67a15e08bce3b1c9a136004516c593672
Author: Pablo Dobarro
Date:   Thu Sep 17 23:51:01 2020 +0200
Branches: master
https://developer.blender.org/rBcacd57b67a15e08bce3b1c9a136004516c593672

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 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)



More information about the Bf-blender-cvs mailing list