diff options
Diffstat (limited to 'source/blender/bmesh/operators/bmo_dissolve.c')
-rw-r--r-- | source/blender/bmesh/operators/bmo_dissolve.c | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/source/blender/bmesh/operators/bmo_dissolve.c b/source/blender/bmesh/operators/bmo_dissolve.c index 209ca30ddc3..8cd9ee14bcb 100644 --- a/source/blender/bmesh/operators/bmo_dissolve.c +++ b/source/blender/bmesh/operators/bmo_dissolve.c @@ -29,6 +29,7 @@ #include "MEM_guardedalloc.h" #include "BLI_array.h" +#include "BLI_stack.h" #include "BLI_math.h" #include "bmesh.h" @@ -51,6 +52,7 @@ #define VERT_MARK_PAIR 4 #define VERT_TAG 2 #define VERT_ISGC 8 +#define VERT_MARK_TEAR 16 @@ -85,15 +87,20 @@ 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) { + BLI_Stack *edge_delete_verts; BMIter iter; BMVert *v; - BMIter liter; + if (use_edge_delete) { + edge_delete_verts = BLI_stack_new(sizeof(BMVert *), __func__); + } + BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) { if (BMO_elem_flag_test(bm, v, oflag)) { if (BM_vert_is_edge_pair(v) == false) { + BMIter liter; BMLoop *l; BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) { if (l->f->len > 3) { @@ -104,8 +111,23 @@ static void bm_face_split(BMesh *bm, const short oflag) } } } + + if (use_edge_delete) { + BLI_stack_push(edge_delete_verts, &v); + } + } + } + } + + if (use_edge_delete) { + while (!BLI_stack_is_empty(edge_delete_verts)) { + /* remove surrounding edges & faces */ + BLI_stack_pop(edge_delete_verts, &v); + while (v->e) { + BM_edge_kill(bm, v->e); } } + BLI_stack_free(edge_delete_verts); } } @@ -268,7 +290,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 +367,29 @@ 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; + } + } + } + } + + bm_face_split(bm, VERT_MARK_TEAR, true); } BMO_ITER (v, &oiter, op->slots_in, "verts", BM_VERT) { |