diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-07-16 10:38:41 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-07-16 10:42:32 +0400 |
commit | d4726c9a4099d13098a1c32145ec4e357a71b751 (patch) | |
tree | e3979da01a675dcd0fedd5db32c5955c3585d544 /source/blender | |
parent | 415af0bec879b6f529fe660acca6a595c667aa5e (diff) |
BMesh: optimize BM_vert_splice to avoid getting a loop array first
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_core.c | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 3072e1acead..47de0441e83 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -1953,10 +1953,6 @@ BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e) */ bool BM_vert_splice(BMesh *bm, BMVert *v, BMVert *v_target) { - void *loops_stack[BM_DEFAULT_ITER_STACK_SIZE]; - BMLoop **loops; - int i, loops_tot; - BMEdge *e; /* verts already spliced */ @@ -1964,21 +1960,23 @@ bool BM_vert_splice(BMesh *bm, BMVert *v, BMVert *v_target) return false; } - /* we can't modify the vert while iterating so first allocate an array of loops */ - loops = BM_iter_as_arrayN(bm, BM_LOOPS_OF_VERT, v, &loops_tot, - loops_stack, BM_DEFAULT_ITER_STACK_SIZE); + /* move all the edges from v's disk to vtarget's disk */ + while ((e = v->e)) { - if (LIKELY(loops != NULL)) { - for (i = 0; i < loops_tot; i++) { - loops[i]->v = v_target; - } - if (loops != (BMLoop **)loops_stack) { - MEM_freeN(loops); + /* 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); } - } - /* move all the edges from v's disk to vtarget's disk */ - while ((e = v->e)) { + /* disk */ bmesh_disk_edge_remove(e, v); bmesh_edge_swapverts(e, v, v_target); bmesh_disk_edge_append(e, v_target); |