[Bf-blender-cvs] [bf49bb354fc] master: Fix T75104: Update Face Sets visibility when entering Sculpt Mode

Pablo Dobarro noreply at git.blender.org
Tue Apr 14 19:25:12 CEST 2020


Commit: bf49bb354fca4ad96f8f3e6802ecf733b29ac3e3
Author: Pablo Dobarro
Date:   Thu Apr 2 15:58:50 2020 +0200
Branches: master
https://developer.blender.org/rBbf49bb354fca4ad96f8f3e6802ecf733b29ac3e3

Fix T75104: Update Face Sets visibility when entering Sculpt Mode

Geometry that was just added to sculpt mode has the SCULPT_FACE_SET_NONE
assigned, so it was hidden by default. By doing this when entering
sculpt mode a new visible face set is created for it, making it easier
to isolate it again if you want to do further tweaking with the sculpt
tools.

Also, this also fixes the issue that may happen when changing the mesh
visibility in edit mode. Now visibility changes done outside sculpt mode
are stored in the face sets when entering sculpt mode, so mesh
visibility should stay the same.

Reviewed By: jbakker

Maniphest Tasks: T75104

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

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

M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index b304a476dec..b8c6e97fcc1 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -7477,6 +7477,28 @@ static void sculpt_init_session(Depsgraph *depsgraph, Scene *scene, Object *ob)
   ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
   ob->sculpt->mode_type = OB_MODE_SCULPT;
   BKE_sculpt_update_object_for_edit(depsgraph, ob, false, false);
+
+  /* Here we can detect geometry that was just added to Sculpt Mode as it has the
+   * SCULPT_FACE_SET_NONE assigned, so we can create a new Face Set for it. */
+  /* In sculpt mode all geometry that is assigned to SCULPT_FACE_SET_NONE is considered as not
+   * initialized, which is used is some operators that modify the mesh topology to preform certain
+   * actions in the new polys. After these operations are finished, all polys should have a valid
+   * face set ID assigned (different from SCULPT_FACE_SET_NONE) to manage their visibility
+   * correctly. */
+  /* TODO(pablodp606): Based on this we can improve the UX in future tools for creating new
+   * objects, like moving the transform pivot position to the new area or masking existing
+   * geometry. */
+  SculptSession *ss = ob->sculpt;
+  const int new_face_set = SCULPT_face_set_next_available_get(ss);
+  for (int i = 0; i < ss->totfaces; i++) {
+    if (ss->face_sets[i] == SCULPT_FACE_SET_NONE) {
+      ss->face_sets[i] = new_face_set;
+    }
+  }
+
+  /* Update the Face Sets visibility with the vertex visibility changes that may have been done
+   * outside Sculpt Mode */
+  SCULPT_visibility_sync_all_vertex_to_face_sets(ob->sculpt);
 }
 
 static int ed_object_sculptmode_flush_recalc_flag(Scene *scene,



More information about the Bf-blender-cvs mailing list