[Bf-blender-cvs] [4e44c6fedfe] temp-face-set-fixes: Fix T74780: Face sets operators not aware of SCULPT_FACE_SET_NONE

Pablo Dobarro noreply at git.blender.org
Wed Mar 25 15:31:32 CET 2020


Commit: 4e44c6fedfedc677b1491656997d5613843b6f5c
Author: Pablo Dobarro
Date:   Wed Mar 25 15:29:55 2020 +0100
Branches: temp-face-set-fixes
https://developer.blender.org/rB4e44c6fedfedc677b1491656997d5613843b6f5c

Fix T74780: Face sets operators not aware of SCULPT_FACE_SET_NONE

SCULPT_FACE_SET_NONE default value is 0 and it is rendered hidden, so
the invert sign operation to show it was not working. Now the show all
function sets this face set to ID 1 before setting its sign.

I also refactored this check in gpu_buffers.

Not related to the reported issue, but the mesh in attached contains non
manifold geometry with hidden loose vertices, so the visibility state
was not syncing correctly to those vertices. Now the toggle operators
checks the current visibility only on the face sets, so no manifold
vertices are ignored (as they are in the rest of operations in sculpt
mode).

Maniphest Tasks: T74780

Differential Revision: https://developer.blender.org/D7188

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

M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/addons_contrib
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/gpu/intern/gpu_buffers.c
M	source/tools

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

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 34d98762cef..885c753570b 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 34d98762cef85b9c065f21a051d1dbe3bf2979b7
+Subproject commit 885c753570b09883a8ddb283dcf09dd9c4f561ab
diff --git a/release/scripts/addons b/release/scripts/addons
index 47a32a5370d..bc1575b6da8 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 47a32a5370d36942674621e5a03e57e8dd4986d8
+Subproject commit bc1575b6da8546fefb8575fb49e5f95c1e8bc2c6
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 70b649775ee..9468c406fb5 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 70b649775eeeebedb02c1c7b7aa996a7f6294177
+Subproject commit 9468c406fb554e32ff47b62bfef356b3908ec651
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index bec44242931..3e6c36730df 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -292,6 +292,11 @@ static void SCULPT_face_sets_visibility_all_set(SculptSession *ss, bool visible)
   switch (BKE_pbvh_type(ss->pbvh)) {
     case PBVH_FACES:
       for (int i = 0; i < ss->totpoly; i++) {
+
+        if (ss->face_sets[i] == SCULPT_FACE_SET_NONE) {
+          ss->face_sets[i] = 1;
+        }
+
         if (visible) {
           ss->face_sets[i] = abs(ss->face_sets[i]);
         }
@@ -10996,19 +11001,25 @@ static int sculpt_face_sets_change_visibility_invoke(bContext *C,
 
   if (mode == SCULPT_FACE_SET_VISIBILITY_TOGGLE) {
     bool hidden_vertex = false;
-    for (int i = 0; i < tot_vert; i++) {
-      if (!SCULPT_vertex_visible_get(ss, i)) {
-        hidden_vertex = true;
-        break;
+
+    /* This can fail with regular meshes with non-manifold geometry as the visibility state can't
+     * be synced from face sets to non-manifold vertices. */
+    if (BKE_pbvh_type(ss->pbvh) == PBVH_GRIDS) {
+      for (int i = 0; i < tot_vert; i++) {
+        if (!SCULPT_vertex_visible_get(ss, i)) {
+          hidden_vertex = true;
+          break;
+        }
       }
     }
 
     for (int i = 0; i < ss->totpoly; i++) {
-      if (ss->face_sets[i] < 0) {
+      if (ss->face_sets[i] <= 0) {
         hidden_vertex = true;
         break;
       }
     }
+
     if (hidden_vertex) {
       SCULPT_face_sets_visibility_all_set(ss, true);
     }
diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c
index c377d196eb5..dd0c08e9bf5 100644
--- a/source/blender/gpu/intern/gpu_buffers.c
+++ b/source/blender/gpu/intern/gpu_buffers.c
@@ -206,6 +206,15 @@ static void face_set_overlay_color_get(const int face_set, const int seed, uchar
   rgba_float_to_uchar(r_color, rgba);
 }
 
+static bool gpu_pbvh_is_looptri_visible(const MLoopTri *lt,
+                                        const MVert *mvert,
+                                        const MLoop *mloop,
+                                        const int *sculpt_face_sets)
+{
+  return (!paint_is_face_hidden(lt, mvert, mloop) && sculpt_face_sets &&
+          sculpt_face_sets[lt->poly] > SCULPT_FACE_SET_NONE);
+}
+
 /* Threaded - do not call any functions that use OpenGL calls! */
 void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
                                   const MVert *mvert,
@@ -313,11 +322,7 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
               buffers->mloop[lt->tri[2]].v,
           };
 
-          if (paint_is_face_hidden(lt, mvert, buffers->mloop)) {
-            continue;
-          }
-
-          if (sculpt_face_sets[lt->poly] <= 0) {
+          if (!gpu_pbvh_is_looptri_visible(lt, mvert, buffers->mloop, sculpt_face_sets)) {
             continue;
           }
 
@@ -381,15 +386,6 @@ void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers,
   buffers->mvert = mvert;
 }
 
-static bool gpu_pbvh_is_looptri_visible(const MLoopTri *lt,
-                                        const MVert *mvert,
-                                        const MLoop *mloop,
-                                        const int *sculpt_face_sets)
-{
-  return (!paint_is_face_hidden(lt, mvert, mloop) && sculpt_face_sets &&
-          sculpt_face_sets[lt->poly] > 0);
-}
-
 /* Threaded - do not call any functions that use OpenGL calls! */
 GPU_PBVH_Buffers *GPU_pbvh_mesh_buffers_build(const int (*face_vert_indices)[3],
                                               const MPoly *mpoly,
diff --git a/source/tools b/source/tools
index 603f076606f..4a6f1706258 160000
--- a/source/tools
+++ b/source/tools
@@ -1 +1 @@
-Subproject commit 603f076606f052adc97d937633bfeb9b268ec202
+Subproject commit 4a6f1706258439db3ee5a50ec6938fef79c7cb97



More information about the Bf-blender-cvs mailing list