diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-01-06 18:50:48 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-01-07 19:03:59 +0300 |
commit | bc9c8c35e17428f3697664274bc54e9c294453c5 (patch) | |
tree | 48ec9660f1a9f4702799f24c96fbef2dfae57386 /source/blender/editors/mesh | |
parent | fdf89acc8634ecba4dfe66e20ff595c0c24ffdee (diff) |
Fix T72830: Check if the mesh has mask data before extractig or slicing
This was causing a crash when the mesh does not have the mask data
initialized. I also added the same check to mask extract as it works the
same way.
Reviewed By: jbakker
Maniphest Tasks: T72830
Differential Revision: https://developer.blender.org/D6513
Diffstat (limited to 'source/blender/editors/mesh')
-rw-r--r-- | source/blender/editors/mesh/editmesh_mask_extract.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c index 0d886360253..28962c8ec01 100644 --- a/source/blender/editors/mesh/editmesh_mask_extract.c +++ b/source/blender/editors/mesh/editmesh_mask_extract.c @@ -80,6 +80,8 @@ static int paint_mask_extract_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); + BKE_sculpt_mask_layers_ensure(ob, NULL); + Mesh *mesh = ob->data; Mesh *new_mesh = BKE_mesh_copy(bmain, mesh); @@ -104,9 +106,8 @@ static int paint_mask_extract_exec(bContext *C, wmOperator *op) BMIter face_iter; /* Delete all unmasked faces */ - const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK); - BLI_assert(cd_vert_mask_offset != -1); BM_mesh_elem_hflag_disable_all(bm, BM_VERT | BM_EDGE | BM_FACE, BM_ELEM_TAG, false); + const int cd_vert_mask_offset = CustomData_get_offset(&bm->vdata, CD_PAINT_MASK); float mask_threshold = RNA_float_get(op->ptr, "mask_threshold"); BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) { @@ -336,6 +337,8 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op) Object *ob = CTX_data_active_object(C); View3D *v3d = CTX_wm_view3d(C); + BKE_sculpt_mask_layers_ensure(ob, NULL); + Mesh *mesh = ob->data; Mesh *new_mesh = BKE_mesh_copy(bmain, mesh); |