diff options
Diffstat (limited to 'source/blender/bmesh/intern')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 37 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_structure.c | 26 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_structure.h | 1 |
3 files changed, 29 insertions, 35 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index c92acfd039e..76b54a45a6b 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -2050,24 +2050,7 @@ bool BM_vert_splice(BMesh *bm, BMVert *v, BMVert *v_target) /* move all the edges from v's disk to vtarget's disk */ while ((e = v->e)) { - - /* loop */ - BMLoop *l_first; - if ((l_first = e->l)) { - BMLoop *l_iter = l_first; - do { - if (l_iter->v == v) { - l_iter->v = v_target; - } - /* else if (l_iter->prev->v == v) {...} - * (this case will be handled by a different edge) */ - } while ((l_iter = l_iter->radial_next) != l_first); - } - - /* disk */ - bmesh_disk_edge_remove(e, v); - bmesh_disk_vert_swap(e, v_target, v); - bmesh_disk_edge_append(e, v_target); + bmesh_edge_vert_swap(e, v_target, v); BLI_assert(e->v1 != e->v2); } @@ -2173,23 +2156,7 @@ void bmesh_vert_separate( } while ((e = BLI_SMALLSTACK_POP(edges))) { - - /* swap out loops */ - if (e->l) { - BMLoop *l_iter, *l_first; - l_iter = l_first = e->l; - do { - if (l_iter->v == v) { - l_iter->v = v_new; - } - } while ((l_iter = l_iter->radial_next) != l_first); - } - - /* swap out edges */ - BLI_assert(e->v1 == v || e->v2 == v); - bmesh_disk_edge_remove(e, v); - bmesh_disk_vert_swap(e, v_new, v); - bmesh_disk_edge_append(e, v_new); + bmesh_edge_vert_swap(e, v_new, v); } if (r_vout) { diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index 3b1dd7e96be..30ab693beb7 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -56,6 +56,32 @@ void bmesh_disk_vert_swap(BMEdge *e, BMVert *v_dst, BMVert *v_src) } /** + * Handles all connected data, use with care. + * + * Assumes caller has setup correct state before the swap is done. + */ +void bmesh_edge_vert_swap(BMEdge *e, BMVert *v_dst, BMVert *v_src) +{ + /* swap out loops */ + if (e->l) { + BMLoop *l_iter, *l_first; + l_iter = l_first = e->l; + do { + if (l_iter->v == v_src) { + l_iter->v = v_dst; + } + } while ((l_iter = l_iter->radial_next) != l_first); + } + + /* swap out edges */ + BLI_assert(e->v1 == v_src || e->v2 == v_src); + bmesh_disk_edge_remove(e, v_src); + bmesh_disk_vert_swap(e, v_dst, v_src); + bmesh_disk_edge_append(e, v_dst); + BLI_assert(e->v1 != e->v2); +} + +/** * \section bm_cycles BMesh Cycles * (this is somewhat outdate, though bits of its API are still used) - joeedh * diff --git a/source/blender/bmesh/intern/bmesh_structure.h b/source/blender/bmesh/intern/bmesh_structure.h index b5ffd9eb67a..9d9fb7f2c68 100644 --- a/source/blender/bmesh/intern/bmesh_structure.h +++ b/source/blender/bmesh/intern/bmesh_structure.h @@ -71,6 +71,7 @@ bool bmesh_radial_validate(int radlen, BMLoop *l) ATTR_WARN_UNUSED_RESULT ATT /* EDGE UTILITIES */ void bmesh_disk_vert_swap(BMEdge *e, BMVert *v_dst, BMVert *v_src) ATTR_NONNULL(); +void bmesh_edge_vert_swap(BMEdge *e, BMVert *v_dst, BMVert *v_src) ATTR_NONNULL(); BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); bool bmesh_disk_validate(int len, BMEdge *e, BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(); |