diff options
Diffstat (limited to 'source/blender/bmesh/intern/bmesh_core.c')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index cf907862120..e72c689ddfb 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -1805,7 +1805,8 @@ BMEdge *bmesh_kernel_join_edge_kill_vert(BMesh *bm, BMVert *v_kill, const bool do_del, const bool check_edge_exists, - const bool kill_degenerate_faces) + const bool kill_degenerate_faces, + const bool kill_duplicate_faces) { BMEdge *e_old; BMVert *v_old, *v_target; @@ -1840,6 +1841,9 @@ BMEdge *bmesh_kernel_join_edge_kill_vert(BMesh *bm, BLI_SMALLSTACK_DECLARE(faces_degenerate, BMFace *); BMLoop *l_kill_next; + /* Candidates for being duplicate. */ + BLI_SMALLSTACK_DECLARE(faces_duplicate_candidate, BMFace *); + #ifndef NDEBUG /* For verification later, count valence of 'v_old' and 'v_target' */ valence1 = bmesh_disk_count(v_old); @@ -1877,9 +1881,14 @@ BMEdge *bmesh_kernel_join_edge_kill_vert(BMesh *bm, /* fix len attribute of face */ l_kill->f->len--; - if (kill_degenerate_faces) { - if (l_kill->f->len < 3) { - BLI_SMALLSTACK_PUSH(faces_degenerate, l_kill->f); + if (kill_degenerate_faces && (l_kill->f->len < 3)) { + BLI_SMALLSTACK_PUSH(faces_degenerate, l_kill->f); + } + else { + /* The duplicate test isn't reliable at this point as `e_splice` might be set, + * so the duplicate test needs to run once the edge has been spliced. */ + if (kill_duplicate_faces) { + BLI_SMALLSTACK_PUSH(faces_duplicate_candidate, l_kill->f); } } l_kill_next = l_kill->radial_next; @@ -1940,6 +1949,15 @@ BMEdge *bmesh_kernel_join_edge_kill_vert(BMesh *bm, } } + if (kill_duplicate_faces) { + BMFace *f_kill; + while ((f_kill = BLI_SMALLSTACK_POP(faces_duplicate_candidate))) { + if (BM_face_find_double(f_kill)) { + BM_face_kill(bm, f_kill); + } + } + } + BM_CHECK_ELEMENT(v_old); BM_CHECK_ELEMENT(v_target); BM_CHECK_ELEMENT(e_old); |