diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-01-17 04:32:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-01-17 06:17:02 +0300 |
commit | 6fac10dd0d6ad601388c378b75459ee78c468384 (patch) | |
tree | 342e935157f9728f9023b4b907b750f624d4a62e /source/blender | |
parent | 4120e535da08708100b6b0a367137b7e86377d4e (diff) |
BMesh: Remove doubles now merges face-flags
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/bmesh/operators/bmo_removedoubles.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/source/blender/bmesh/operators/bmo_removedoubles.c b/source/blender/bmesh/operators/bmo_removedoubles.c index 937ab385678..ed06090bb79 100644 --- a/source/blender/bmesh/operators/bmo_removedoubles.c +++ b/source/blender/bmesh/operators/bmo_removedoubles.c @@ -78,7 +78,7 @@ static void remdoubles_splitface(BMFace *f, BMesh *bm, BMOperator *op, BMOpSlot /** * helper function for bmo_weld_verts_exec so we can use stack memory */ -static BMFace *remdoubles_createface(BMesh *bm, BMFace *f, BMOpSlot *slot_targetmap) +static BMFace *remdoubles_createface(BMesh *bm, BMFace *f, BMOpSlot *slot_targetmap, bool *r_created) { BMEdge *e_new; @@ -94,6 +94,7 @@ static BMFace *remdoubles_createface(BMesh *bm, BMFace *f, BMOpSlot *slot_target STACK_INIT(loops, f->len); STACK_INIT(verts, f->len); + *r_created = false; { #define LOOP_MAP_VERT_INIT(l_init, v_map, is_del) \ @@ -160,20 +161,23 @@ finally: } if (STACK_SIZE(edges) >= 3) { - if (!BM_face_exists(verts, STACK_SIZE(edges))) { - BMFace *f_new = BM_face_create(bm, verts, edges, STACK_SIZE(edges), f, BM_CREATE_NOP); - BLI_assert(f_new != f); - - if (f_new) { - uint i = 0; - BMLoop *l_iter, *l_first; - l_iter = l_first = BM_FACE_FIRST_LOOP(f_new); - do { - BM_elem_attrs_copy(bm, bm, loops[i], l_iter); - } while ((void)i++, (l_iter = l_iter->next) != l_first); - - return f_new; - } + BMFace *f_new = BM_face_exists(verts, STACK_SIZE(verts)); + if (f_new) { + return f_new; + } + f_new = BM_face_create(bm, verts, edges, STACK_SIZE(edges), f, BM_CREATE_NOP); + BLI_assert(f_new != f); + + if (f_new) { + uint i = 0; + BMLoop *l_iter, *l_first; + l_iter = l_first = BM_FACE_FIRST_LOOP(f_new); + do { + BM_elem_attrs_copy(bm, bm, loops[i], l_iter); + } while ((void)i++, (l_iter = l_iter->next) != l_first); + + *r_created = true; + return f_new; } } @@ -258,19 +262,24 @@ void bmo_weld_verts_exec(BMesh *bm, BMOperator *op) BMO_face_flag_enable(bm, f, ELE_DEL); if (f->len - edge_collapse >= 3) { - BMFace *f_new = remdoubles_createface(bm, f, slot_targetmap); + bool created; + BMFace *f_new = remdoubles_createface(bm, f, slot_targetmap, &created); /* do this so we don't need to return a list of created faces */ if (f_new) { - bmesh_face_swap_data(f_new, f); - - if (bm->use_toolflags) { - SWAP(BMFlagLayer *, ((BMFace_OFlag *)f)->oflags, ((BMFace_OFlag *)f_new)->oflags); - } + if (created) { + bmesh_face_swap_data(f_new, f); - BMO_face_flag_disable(bm, f, ELE_DEL); + if (bm->use_toolflags) { + SWAP(BMFlagLayer *, ((BMFace_OFlag *)f)->oflags, ((BMFace_OFlag *)f_new)->oflags); + } - BM_face_kill(bm, f_new); + BMO_face_flag_disable(bm, f, ELE_DEL); + BM_face_kill(bm, f_new); + } + else { + BM_elem_flag_merge_ex(f_new, f, BM_ELEM_HIDDEN); + } } } } |