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) {
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;

@ -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,13 +776,14 @@ 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;
@ -794,8 +793,6 @@ void bmo_esubd_exec(BMesh *bmesh, BMOperator *op)
totesel++;
}
i++;
}
/* 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) {
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! */