Editmesh: Add option to tear boundary vertices when dissolving

This commit is contained in:
Campbell Barton 2014-07-24 03:26:24 +10:00
parent 554829dc9e
commit 1f55044617
3 changed files with 39 additions and 4 deletions

View File

@ -956,6 +956,7 @@ static BMOpDefine bmo_dissolve_verts_def = {
/* slots_in */
{{"verts", BMO_OP_SLOT_ELEMENT_BUF, {BM_VERT}},
{"use_face_split", BMO_OP_SLOT_BOOL},
{"use_boundary_tear", BMO_OP_SLOT_BOOL},
{{'\0'}},
},
{{{'\0'}}}, /* no output */

View File

@ -51,6 +51,7 @@
#define VERT_MARK_PAIR 4
#define VERT_TAG 2
#define VERT_ISGC 8
#define VERT_MARK_TEAR 16
@ -85,7 +86,7 @@ static bool UNUSED_FUNCTION(check_hole_in_region) (BMesh *bm, BMFace *f)
return true;
}
static void bm_face_split(BMesh *bm, const short oflag)
static void bm_face_split(BMesh *bm, const short oflag, bool use_edge_delete)
{
BMIter iter;
BMVert *v;
@ -104,6 +105,12 @@ static void bm_face_split(BMesh *bm, const short oflag)
}
}
}
/* remove surrounding edges & faces */
if (use_edge_delete) {
while (v->e) {
BM_edge_kill(bm, v->e);
}
}
}
}
}
@ -268,7 +275,7 @@ void bmo_dissolve_edges_exec(BMesh *bm, BMOperator *op)
}
}
bm_face_split(bm, VERT_TAG);
bm_face_split(bm, VERT_TAG, false);
}
if (use_verts) {
@ -345,13 +352,30 @@ void bmo_dissolve_verts_exec(BMesh *bm, BMOperator *op)
BMFace *act_face = bm->act_face;
const bool use_face_split = BMO_slot_bool_get(op->slots_in, "use_face_split");
const bool use_boundary_tear = BMO_slot_bool_get(op->slots_in, "use_boundary_tear");
BMO_ITER (v, &oiter, op->slots_in, "verts", BM_VERT) {
BMO_elem_flag_enable(bm, v, VERT_MARK | VERT_ISGC);
}
if (use_face_split) {
bm_face_split(bm, VERT_MARK);
bm_face_split(bm, VERT_MARK, false);
}
if (use_boundary_tear) {
BMO_ITER (v, &oiter, op->slots_in, "verts", BM_VERT) {
if (!BM_vert_is_edge_pair(v)) {
BM_ITER_ELEM (e, &iter, v, BM_EDGES_OF_VERT) {
if (BM_edge_is_boundary(e)) {
BMO_elem_flag_enable(bm, v, VERT_MARK_TEAR);
break;
}
}
}
}
if (!use_face_split) {
bm_face_split(bm, VERT_MARK_TEAR, true);
}
}
BMO_ITER (v, &oiter, op->slots_in, "verts", BM_VERT) {

View File

@ -3479,6 +3479,11 @@ static void edbm_dissolve_prop__use_face_split(wmOperatorType *ot)
RNA_def_boolean(ot->srna, "use_face_split", 0, "Face Split",
"Split off face corners to maintain surrounding geometry");
}
static void edbm_dissolve_prop__use_boundary_tear(wmOperatorType *ot)
{
RNA_def_boolean(ot->srna, "use_boundary_tear", 0, "Tear Boundary",
"Split off face corners instead of merging faces");
}
static int edbm_dissolve_verts_exec(bContext *C, wmOperator *op)
{
@ -3486,8 +3491,11 @@ static int edbm_dissolve_verts_exec(bContext *C, wmOperator *op)
BMEditMesh *em = BKE_editmesh_from_object(obedit);
const bool use_face_split = RNA_boolean_get(op->ptr, "use_face_split");
const bool use_boundary_tear = RNA_boolean_get(op->ptr, "use_boundary_tear");
if (!EDBM_op_callf(em, op, "dissolve_verts verts=%hv use_face_split=%b", BM_ELEM_SELECT, use_face_split))
if (!EDBM_op_callf(em, op,
"dissolve_verts verts=%hv use_face_split=%b use_boundary_tear=%b",
BM_ELEM_SELECT, use_face_split, use_boundary_tear))
return OPERATOR_CANCELLED;
EDBM_update_generic(em, true, true);
@ -3510,6 +3518,7 @@ void MESH_OT_dissolve_verts(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
edbm_dissolve_prop__use_face_split(ot);
edbm_dissolve_prop__use_boundary_tear(ot);
}
static int edbm_dissolve_edges_exec(bContext *C, wmOperator *op)
@ -3621,6 +3630,7 @@ void MESH_OT_dissolve_mode(wmOperatorType *ot)
edbm_dissolve_prop__use_verts(ot);
edbm_dissolve_prop__use_face_split(ot);
edbm_dissolve_prop__use_boundary_tear(ot);
}
static int edbm_dissolve_limited_exec(bContext *C, wmOperator *op)