diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-07-23 21:26:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-07-23 21:29:17 +0400 |
commit | 1f55044617d167e81bc56cc359a1adf886045447 (patch) | |
tree | 38101dd59aafffc078157765ef41e3be4ef0ddca /source/blender/bmesh | |
parent | 554829dc9e4c9f5d55ec4a9b95c50a9b40a33e3b (diff) |
Editmesh: Add option to tear boundary vertices when dissolving
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 1 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_dissolve.c | 30 |
2 files changed, 28 insertions, 3 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index b9da7618df8..7dc46cf0678 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -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 */ diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 209ca30ddc3..84d3cda4866 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -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) { |