diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-12-19 13:13:06 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-12-19 13:13:06 +0400 |
commit | fbf4f57cd6c20d72ca3d13ab021ff6b069d68240 (patch) | |
tree | f8ad3b026091844a984da939db991487a3a0cce5 /source/blender/bmesh | |
parent | 62988549a1810814d590c7852741e4aa5b72eec9 (diff) |
bmesh optimization: use BM_face_create() rather then BM_face_create_ngon() in BM_mesh_copy(), gives ~30% overall speedup in my tests.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 87192d6610f..ebbf4b2b4d8 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -816,6 +816,8 @@ void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *sour BMesh *BM_mesh_copy(BMesh *bm_old) { +#define USE_FAST_FACE_COPY + BMesh *bm_new; BMVert *v, *v2, **vtable = NULL; BMEdge *e, *e2, **edges = NULL, **etable = NULL; @@ -823,6 +825,10 @@ BMesh *BM_mesh_copy(BMesh *bm_old) BLI_array_declare(edges); BMLoop *l, /* *l2, */ **loops = NULL; BLI_array_declare(loops); +#ifdef USE_FAST_FACE_COPY + BMVert **verts = NULL; + BLI_array_declare(verts); +#endif BMFace *f, *f2, **ftable = NULL; BMEditSelection *ese; BMIter iter, liter; @@ -890,12 +896,24 @@ BMesh *BM_mesh_copy(BMesh *bm_old) BLI_array_grow_items(loops, f->len); BLI_array_grow_items(edges, f->len); +#ifdef USE_FAST_FACE_COPY + BLI_array_empty(verts); + BLI_array_grow_items(verts, f->len); +#endif + l = BM_iter_new(&liter, bm_old, BM_LOOPS_OF_FACE, f); for (j = 0; j < f->len; j++, l = BM_iter_step(&liter)) { loops[j] = l; edges[j] = etable[BM_elem_index_get(l->e)]; + +#ifdef USE_FAST_FACE_COPY + verts[j] = vtable[BM_elem_index_get(l->v)]; +#endif } +#ifdef USE_FAST_FACE_COPY + f2 = BM_face_create(bm_new, verts, edges, f->len, BM_CREATE_SKIP_CD); +#else v = vtable[BM_elem_index_get(loops[0]->v)]; v2 = vtable[BM_elem_index_get(loops[1]->v)]; @@ -905,6 +923,8 @@ BMesh *BM_mesh_copy(BMesh *bm_old) } f2 = BM_face_create_ngon(bm_new, v, v2, edges, f->len, BM_CREATE_SKIP_CD); +#endif + if (UNLIKELY(f2 == NULL)) { continue; } |