diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-03-09 21:39:45 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-03-09 21:39:57 +0300 |
commit | 0030e6a2fc265258be7e02bedb89d81feda2adda (patch) | |
tree | 97ce57399a15978c812be3a897f1bf300475e552 /source | |
parent | 503d5c0c652dbce9dad428ab4b19e021c0ca8a39 (diff) |
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/mesh/editmesh_mask_extract.c | 11 |
1 files changed, 11 insertions, 0 deletions
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); |