[Bf-blender-cvs] [55740b7bee4] sculpt-dev: Sculpt-dev: make mask slice work in dyntopo mode.
Joseph Eagar
noreply at git.blender.org
Mon Apr 18 21:50:53 CEST 2022
Commit: 55740b7bee4e9ce1d1329e136533121669de8145
Author: Joseph Eagar
Date: Mon Apr 18 12:50:31 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB55740b7bee4e9ce1d1329e136533121669de8145
Sculpt-dev: make mask slice work in dyntopo mode.
===================================================================
M source/blender/editors/mesh/editmesh_mask_extract.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
===================================================================
diff --git a/source/blender/editors/mesh/editmesh_mask_extract.c b/source/blender/editors/mesh/editmesh_mask_extract.c
index 52dc6ac9b52..b7c8dc058e4 100644
--- a/source/blender/editors/mesh/editmesh_mask_extract.c
+++ b/source/blender/editors/mesh/editmesh_mask_extract.c
@@ -496,18 +496,25 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
}
BMesh *bm;
- const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh);
- bm = BM_mesh_create(&allocsize,
- &((struct BMeshCreateParams){
- .use_toolflags = true,
- }));
- BM_mesh_bm_from_me(NULL,
- bm,
- new_mesh,
- (&(struct BMeshFromMeshParams){
- .calc_face_normal = true,
- }));
+ if (ob->sculpt && ob->sculpt->bm) {
+ bm = ob->sculpt->bm;
+ BM_mesh_elem_toolflags_ensure(bm);
+ }
+ else {
+ const BMAllocTemplate allocsize = BMALLOC_TEMPLATE_FROM_ME(new_mesh);
+ bm = BM_mesh_create(&allocsize,
+ &((struct BMeshCreateParams){
+ .use_toolflags = true,
+ }));
+
+ BM_mesh_bm_from_me(NULL,
+ bm,
+ new_mesh,
+ (&(struct BMeshFromMeshParams){
+ .calc_face_normal = true,
+ }));
+ }
slice_paint_mask(
bm, false, RNA_boolean_get(op->ptr, "fill_holes"), RNA_float_get(op->ptr, "mask_threshold"));
@@ -517,7 +524,12 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
.calc_object_remap = false,
}),
mesh);
- BM_mesh_free(bm);
+ if (!ob->sculpt || !ob->sculpt->bm) {
+ BM_mesh_free(bm);
+ }
+ else {
+ BM_mesh_elem_toolflags_clear(bm);
+ }
if (RNA_boolean_get(op->ptr, "new_object")) {
ushort local_view_bits = 0;
@@ -551,7 +563,6 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
.calc_object_remap = false,
}),
mesh);
- BM_mesh_free(bm);
/* Remove the mask from the new object so it can be sculpted directly after slicing. */
CustomData_free_layers(&new_ob_mesh->vdata, CD_PAINT_MASK, new_ob_mesh->totvert);
@@ -588,11 +599,23 @@ static int paint_mask_slice_exec(bContext *C, wmOperator *op)
case PBVH_BMESH: {
if (ss->bm && CustomData_has_layer(&ss->bm->pdata, CD_SCULPT_FACE_SETS)) {
const int cd_fset = CustomData_get_offset(&ss->bm->pdata, CD_SCULPT_FACE_SETS);
+ const int cd_sculptvert = CustomData_get_offset(&ss->bm->vdata, CD_DYNTOPO_VERT);
+
BMFace *f;
+ BMVert *v;
BMIter iter;
const int next_face_set_id = SCULPT_face_set_next_available_get(ss);
+ const int updateflag = SCULPTVERT_NEED_BOUNDARY | SCULPTVERT_NEED_VALENCE |
+ SCULPTVERT_NEED_TRIANGULATE | SCULPTVERT_NEED_DISK_SORT;
+
+ BM_ITER_MESH (v, &iter, ss->bm, BM_VERTS_OF_MESH) {
+ MSculptVert *mv = BM_ELEM_CD_GET_VOID_P(v, cd_sculptvert);
+
+ mv->flag |= updateflag;
+ }
+
BM_ITER_MESH (f, &iter, ss->bm, BM_FACES_OF_MESH) {
int fset = BM_ELEM_CD_GET_INT(f, cd_fset);
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c
index a0535ef8509..469fee90584 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -2659,7 +2659,7 @@ static UndoSculpt *sculpt_undo_get_nodes(void)
}
UndoStep *us = BKE_undosys_stack_init_or_active_with_type(ustack, BKE_UNDOSYS_TYPE_SCULPT);
- return sculpt_undosys_step_get_nodes(us);
+ return us ? sculpt_undosys_step_get_nodes(us) : NULL;
}
void SCULPT_on_sculptsession_bmesh_free(SculptSession *ss)
More information about the Bf-blender-cvs
mailing list