diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-12-19 13:45:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-12-19 13:45:56 +0400 |
commit | 2cb39ea9da3ce5dd45a0be6f997a0c1d942ad4fc (patch) | |
tree | dbc8f2cebab8a6db7596aaf102a10da9d2d179a5 | |
parent | fbf4f57cd6c20d72ca3d13ab021ff6b069d68240 (diff) |
use BM_face_create() over BM_face_create_ngon() in bevel and extrude individual faces to get some speedup.
-rw-r--r-- | source/blender/bmesh/intern/bmesh_construct.c | 5 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_extrude.c | 22 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 4 |
3 files changed, 24 insertions, 7 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index ebbf4b2b4d8..468a80f44f8 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -980,9 +980,12 @@ BMesh *BM_mesh_copy(BMesh *bm_old) MEM_freeN(vtable); MEM_freeN(ftable); +#ifdef USE_FAST_FACE_COPY + BLI_array_free(verts); +#endif + BLI_array_free(loops); BLI_array_free(edges); - return bm_new; } diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index bf3bafc57fb..956d9e5767e 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -51,28 +51,35 @@ enum { void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) { + BMVert **verts = NULL; + BLI_array_declare(verts); + BMEdge **edges = NULL; + BLI_array_declare(edges); + BMOIter siter; BMIter liter, liter2; BMFace *f, *f2, *f3; BMLoop *l, *l2, *l3, *l4, *l_tmp; - BMEdge **edges = NULL, *e, *laste; + BMEdge *e, *laste; BMVert *v, *lastv, *firstv; - BLI_array_declare(edges); int i; BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) { + BLI_array_empty(verts); BLI_array_empty(edges); + BLI_array_grow_items(verts, f->len); BLI_array_grow_items(edges, f->len); i = 0; firstv = lastv = NULL; BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { v = BM_vert_create(bm, l->v->co, l->v, 0); - /* skip on the first iteration */ if (lastv) { e = BM_edge_create(bm, lastv, v, l->e, 0); - edges[i++] = e; + edges[i] = e; + verts[i] = lastv; + i++; } lastv = v; @@ -82,11 +89,13 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) /* this fits in the array because we skip one in the loop above */ e = BM_edge_create(bm, v, firstv, laste, 0); - edges[i++] = e; + edges[i] = e; + verts[i] = lastv; + i++; BMO_elem_flag_enable(bm, f, EXT_DEL); - f2 = BM_face_create_ngon(bm, firstv, BM_edge_other_vert(edges[0], firstv), edges, f->len, 0); + f2 = BM_face_create(bm, verts, edges, f->len, 0); if (UNLIKELY(f2 == NULL)) { BMO_error_raise(bm, op, BMERR_MESH_ERROR, "Extrude failed: could not create face"); BLI_array_free(edges); @@ -117,6 +126,7 @@ void bmo_extrude_discrete_faces_exec(BMesh *bm, BMOperator *op) } } + BLI_array_free(verts); BLI_array_free(edges); BMO_op_callf(bm, op->flag, diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index cc472e4a501..fbac538eb7f 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -269,7 +269,11 @@ static BMFace *bev_create_ngon(BMesh *bm, BMVert **vert_arr, const int totv, BMF for (i = 0; i < totv; i++) { ee[i] = BM_edge_create(bm, vert_arr[i], vert_arr[(i + 1) % totv], NULL, BM_CREATE_NO_DOUBLE); } +#if 0 f = BM_face_create_ngon(bm, vert_arr[0], vert_arr[1], ee, totv, 0); +#else + f = BM_face_create(bm, vert_arr, ee, totv, 0); +#endif } if (facerep && f) { int has_mdisps = CustomData_has_layer(&bm->ldata, CD_MDISPS); |