[Bf-blender-cvs] [0030e6a2fc2] master: Fix T74500: Rebuild the Face Sets datalayer after slicing the geometry

Pablo Dobarro noreply at git.blender.org
Mon Mar 9 19:41:07 CET 2020


Commit: 0030e6a2fc265258be7e02bedb89d81feda2adda
Author: Pablo Dobarro
Date:   Mon Mar 9 19:39:45 2020 +0100
Branches: master
https://developer.blender.org/rB0030e6a2fc265258be7e02bedb89d81feda2adda

Fix T74500: Rebuild the Face Sets datalayer after slicing the geometry

Was crashing SculptSession data will not longer be valid if the total
number of polys is modified when rendering the mesh again.
This deletes all face sets in the mesh when slicing the mask. I'll try
to add code to generate a new face set in with faces that are created
when filling the holes, but for now this avoids the crash.

Reviewed By: brecht

Maniphest Tasks: T74500

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

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

M	source/blender/editors/mesh/editmesh_mask_extract.c

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

diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c
index e604248874a..d688e2cb658 100644
--- a/source/blender/editors/mesh/editmesh_mask_extract.c
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -348,6 +348,10 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
 
   if (ob->mode == OB_MODE_SCULPT) {
     ED_sculpt_undo_geometry_begin(ob, "mask slice");
+    /* TODO: The ideal functionality would be to preserve the current face sets and add a new one
+     * for the new triangles, but this datalayer needs to be rebuild in order to make sculpt mode
+     * not crash when modifying the geometry. */
+    CustomData_free_layers(&mesh->pdata, CD_SCULPT_FACE_SETS, mesh->totpoly);
   }
 
   BMesh *bm;
@@ -420,6 +424,13 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
 
   if (ob->mode == OB_MODE_SCULPT) {
     ED_sculpt_undo_geometry_end(ob);
+    SculptSession *ss = ob->sculpt;
+    /* Rebuild a new valid Face Set layer for the object. */
+    ss->face_sets = CustomData_add_layer(
+        &mesh->pdata, CD_SCULPT_FACE_SETS, CD_CALLOC, NULL, mesh->totpoly);
+    for (int i = 0; i < mesh->totpoly; i++) {
+      ss->face_sets[i] = 1;
+    }
   }
 
   BKE_mesh_batch_cache_dirty_tag(ob->data, BKE_MESH_BATCH_DIRTY_ALL);



More information about the Bf-blender-cvs mailing list