diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-04-06 15:50:16 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-04-06 15:50:16 +0400 |
commit | 11a4dab32bcc7402180809525656fd3df56adb24 (patch) | |
tree | f8d4dec35b7220c0c534e6b40b408c91789f6a31 /source/blender/bmesh/operators | |
parent | 186f018e6ee81edef14255c9fd9b6d7b5480449b (diff) |
bmesh minor change - avoid increasing array sizes one by one and use iterator macros.
Diffstat (limited to 'source/blender/bmesh/operators')
-rw-r--r-- | source/blender/bmesh/operators/bmo_extrude.c | 7 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_subdivide.c | 19 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_utils.c | 11 |
3 files changed, 17 insertions, 20 deletions
diff --git a/source/blender/bmesh/operators/bmo_extrude.c b/source/blender/bmesh/operators/bmo_extrude.c index 1ac6f6f19f0..fa4c3c5751b 100644 --- a/source/blender/bmesh/operators/bmo_extrude.c +++ b/source/blender/bmesh/operators/bmo_extrude.c @@ -58,13 +58,14 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) { BLI_array_empty(edges); + BLI_array_growitems(edges, f->len); + i = 0; firstv = lastv = NULL; BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { - BLI_array_growone(edges); - v = BM_vert_create(bm, l->v->co, l->v); + /* skip on the first iteration */ if (lastv) { e = BM_edge_create(bm, lastv, v, l->e, FALSE); edges[i++] = e; @@ -75,7 +76,7 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op) if (!firstv) firstv = v; } - BLI_array_growone(edges); + /* this fits in the array because we skip one in the loop above */ e = BM_edge_create(bm, v, firstv, laste, FALSE); edges[i++] = e; diff --git a/source/blender/bmesh/operators/bmo_subdivide.c b/source/blender/bmesh/operators/bmo_subdivide.c index e3ba4c63314..b011bb32449 100644 --- a/source/blender/bmesh/operators/bmo_subdivide.c +++ b/source/blender/bmesh/operators/bmo_subdivide.c @@ -767,10 +767,8 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) BMO_slot_map_to_flag(bmesh, op, "edgepercents", BM_EDGE, EDGE_PERCENT); - for (face = BM_iter_new(&fiter, bmesh, BM_FACES_OF_MESH, NULL); - face; - face = BM_iter_step(&fiter)) - { + + BM_ITER(face, &fiter, bmesh, BM_FACES_OF_MESH, NULL) { BMEdge *e1 = NULL, *e2 = NULL; float vec1[3], vec2[3]; @@ -778,24 +776,23 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op) BLI_array_empty(edges); BLI_array_empty(verts); + + BLI_array_growitems(edges, face->len); + BLI_array_growitems(verts, face->len); + matched = 0; - i = 0; totesel = 0; - for (nl = BM_iter_new(&liter, bmesh, BM_LOOPS_OF_FACE, face); nl; nl = BM_iter_step(&liter)) { - BLI_array_growone(edges); - BLI_array_growone(verts); + BM_ITER_INDEX(nl, &liter, bmesh, BM_LOOPS_OF_FACE, face, i) { edges[i] = nl->e; verts[i] = nl->v; if (BMO_elem_flag_test(bmesh, edges[i], SUBD_SPLIT)) { if (!e1) e1 = edges[i]; - else e2 = edges[i]; + else e2 = edges[i]; totesel++; } - - i++; } /* make sure the two edges have a valid angle to each other */ diff --git a/source/blender/bmesh/operators/bmo_utils.c b/source/blender/bmesh/operators/bmo_utils.c index 47c9f9ce005..c359d530f73 100644 --- a/source/blender/bmesh/operators/bmo_utils.c +++ b/source/blender/bmesh/operators/bmo_utils.c @@ -1083,17 +1083,16 @@ void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op) BMO_ITER(fs, &fs_iter, bm, op, "faces", BM_FACE) { if (CustomData_has_layer(&(bm->ldata), CD_MLOOPUV)) { BMLoop *lf; /* current face loops */ - int i = 0; + int i; BLI_array_empty(uvs); - BM_ITER(lf, &l_iter, bm, BM_LOOPS_OF_FACE, fs) { + BLI_array_growitems(uvs, fs->len); + + BM_ITER_INDEX(lf, &l_iter, bm, BM_LOOPS_OF_FACE, fs, i) { MLoopUV *luv = CustomData_bmesh_get(&bm->ldata, lf->head.data, CD_MLOOPUV); /* current loop uv is the previous loop uv */ - BLI_array_growone(uvs); - uvs[i][0] = luv->uv[0]; - uvs[i][1] = luv->uv[1]; - i++; + copy_v2_v2(uvs[i], luv->uv); } /* now that we have the uvs in the array, reverse! */ |