bmesh minor change - avoid increasing array sizes one by one and use iterator macros.

This commit is contained in:
Campbell Barton 2012-04-06 11:50:16 +00:00
parent 186f018e6e
commit 11a4dab32b
3 changed files with 17 additions and 20 deletions

@ -58,13 +58,14 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op)
BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) { BMO_ITER(f, &siter, bm, op, "faces", BM_FACE) {
BLI_array_empty(edges); BLI_array_empty(edges);
BLI_array_growitems(edges, f->len);
i = 0; i = 0;
firstv = lastv = NULL; firstv = lastv = NULL;
BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) { BM_ITER(l, &liter, bm, BM_LOOPS_OF_FACE, f) {
BLI_array_growone(edges);
v = BM_vert_create(bm, l->v->co, l->v); v = BM_vert_create(bm, l->v->co, l->v);
/* skip on the first iteration */
if (lastv) { if (lastv) {
e = BM_edge_create(bm, lastv, v, l->e, FALSE); e = BM_edge_create(bm, lastv, v, l->e, FALSE);
edges[i++] = e; edges[i++] = e;
@ -75,7 +76,7 @@ void bmo_extrude_face_indiv_exec(BMesh *bm, BMOperator *op)
if (!firstv) firstv = v; 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); e = BM_edge_create(bm, v, firstv, laste, FALSE);
edges[i++] = e; edges[i++] = e;

@ -767,10 +767,8 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
BMO_slot_map_to_flag(bmesh, op, "edgepercents", BMO_slot_map_to_flag(bmesh, op, "edgepercents",
BM_EDGE, EDGE_PERCENT); BM_EDGE, EDGE_PERCENT);
for (face = BM_iter_new(&fiter, bmesh, BM_FACES_OF_MESH, NULL);
face; BM_ITER(face, &fiter, bmesh, BM_FACES_OF_MESH, NULL) {
face = BM_iter_step(&fiter))
{
BMEdge *e1 = NULL, *e2 = NULL; BMEdge *e1 = NULL, *e2 = NULL;
float vec1[3], vec2[3]; float vec1[3], vec2[3];
@ -778,13 +776,14 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
BLI_array_empty(edges); BLI_array_empty(edges);
BLI_array_empty(verts); BLI_array_empty(verts);
BLI_array_growitems(edges, face->len);
BLI_array_growitems(verts, face->len);
matched = 0; matched = 0;
i = 0;
totesel = 0; totesel = 0;
for (nl = BM_iter_new(&liter, bmesh, BM_LOOPS_OF_FACE, face); nl; nl = BM_iter_step(&liter)) { BM_ITER_INDEX(nl, &liter, bmesh, BM_LOOPS_OF_FACE, face, i) {
BLI_array_growone(edges);
BLI_array_growone(verts);
edges[i] = nl->e; edges[i] = nl->e;
verts[i] = nl->v; verts[i] = nl->v;
@ -794,8 +793,6 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
totesel++; totesel++;
} }
i++;
} }
/* make sure the two edges have a valid angle to each other */ /* make sure the two edges have a valid angle to each other */

@ -1083,17 +1083,16 @@ void bmo_face_reverseuvs_exec(BMesh *bm, BMOperator *op)
BMO_ITER(fs, &fs_iter, bm, op, "faces", BM_FACE) { BMO_ITER(fs, &fs_iter, bm, op, "faces", BM_FACE) {
if (CustomData_has_layer(&(bm->ldata), CD_MLOOPUV)) { if (CustomData_has_layer(&(bm->ldata), CD_MLOOPUV)) {
BMLoop *lf; /* current face loops */ BMLoop *lf; /* current face loops */
int i = 0; int i;
BLI_array_empty(uvs); 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); MLoopUV *luv = CustomData_bmesh_get(&bm->ldata, lf->head.data, CD_MLOOPUV);
/* current loop uv is the previous loop uv */ /* current loop uv is the previous loop uv */
BLI_array_growone(uvs); copy_v2_v2(uvs[i], luv->uv);
uvs[i][0] = luv->uv[0];
uvs[i][1] = luv->uv[1];
i++;
} }
/* now that we have the uvs in the array, reverse! */ /* now that we have the uvs in the array, reverse! */