code cleanup: use iterator macros, and replace BM_LOOPS_OF_FACE with direct loop...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 24 Jul 2013 18:38:55 +0000 (18:38 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 24 Jul 2013 18:38:55 +0000 (18:38 +0000)
source/blender/bmesh/intern/bmesh_mesh_conv.c
source/blender/bmesh/operators/bmo_dupe.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/editmesh_tools.c

index 7c4af8eaa3b745ed00782c5f96dac451904b53ce..184fed59f011204e14f7854c537ae637b9018416 100644 (file)
@@ -583,9 +583,8 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
        MEdge *med, *medge;
        BMVert *v, *eve;
        BMEdge *e;
-       BMLoop *l;
        BMFace *f;
-       BMIter iter, liter;
+       BMIter iter;
        int i, j, ototvert;
 
        const int cd_vert_bweight_offset = CustomData_get_offset(&bm->vdata, CD_BWEIGHT);
@@ -699,22 +698,26 @@ void BM_mesh_bm_to_me(BMesh *bm, Mesh *me, bool do_tessface)
        i = 0;
        j = 0;
        BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
+               BMLoop *l_iter, *l_first;
                mpoly->loopstart = j;
                mpoly->totloop = f->len;
                mpoly->mat_nr = f->mat_nr;
                mpoly->flag = BM_face_flag_to_mflag(f);
 
-               l = BM_iter_new(&liter, bm, BM_LOOPS_OF_FACE, f);
-               for ( ; l; l = BM_iter_step(&liter), j++, mloop++) {
-                       mloop->e = BM_elem_index_get(l->e);
-                       mloop->v = BM_elem_index_get(l->v);
+               l_iter = l_first = BM_FACE_FIRST_LOOP(f);
+               do {
+                       mloop->e = BM_elem_index_get(l_iter->e);
+                       mloop->v = BM_elem_index_get(l_iter->v);
 
-                       /* copy over customdat */
-                       CustomData_from_bmesh_block(&bm->ldata, &me->ldata, l->head.data, j);
-                       BM_CHECK_ELEMENT(l);
-                       BM_CHECK_ELEMENT(l->e);
-                       BM_CHECK_ELEMENT(l->v);
-               }
+                       /* copy over customdata */
+                       CustomData_from_bmesh_block(&bm->ldata, &me->ldata, l_iter->head.data, j);
+
+                       j++;
+                       mloop++;
+                       BM_CHECK_ELEMENT(l_iter);
+                       BM_CHECK_ELEMENT(l_iter->e);
+                       BM_CHECK_ELEMENT(l_iter->v);
+               } while ((l_iter = l_iter->next) != l_first);
 
                if (f == bm->act_face) me->act_face = i;
 
index d65e2669a58dfd3363920139390cdbda3ce8df59..481039694740db1a535a2f5b165289d5346512bf 100644 (file)
@@ -150,10 +150,7 @@ static BMFace *copy_face(BMOperator *op,
 #endif
 
        /* lookup edge */
-       for (i = 0, source_loop = BM_iter_new(&iter, source_mesh, BM_LOOPS_OF_FACE, source_face);
-            source_loop;
-            source_loop = BM_iter_step(&iter), i++)
-       {
+       BM_ITER_ELEM_INDEX (source_loop, &iter, source_face, BM_LOOPS_OF_FACE, i) {
                vtar[i] = BLI_ghash_lookup(vhash, source_loop->v);
                edar[i] = BLI_ghash_lookup(ehash, source_loop->e);
        }
index 6f0f829554103728c24011786a08307a2b075328..4ccb2a59b45e6c52b36e2d4aee7652aeaea15f3a 100644 (file)
@@ -1590,8 +1590,7 @@ void EDBM_selectmode_set(BMEditMesh *em)
                }
 
                if (em->bm->totfacesel) {
-                       efa = BM_iter_new(&iter, em->bm, BM_FACES_OF_MESH, NULL);
-                       for (; efa; efa = BM_iter_step(&iter)) {
+                       BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                                if (BM_elem_flag_test(efa, BM_ELEM_SELECT)) {
                                        BM_face_select_set(em->bm, efa, true);
                                }
index bf9dd03f170dd26ba75fb7f7f7eb7299bd1f37bd..e152c83fb9af12df1f4cc6edb64741282e2e372b 100644 (file)
@@ -2277,7 +2277,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op)
 
        /* store percentage of edge cut for KNIFE_EXACT here.*/
        slot_edge_percents = BMO_slot_get(bmop.slots_in, "edge_percents");
-       for (be = BM_iter_new(&iter, bm, BM_EDGES_OF_MESH, NULL); be; be = BM_iter_step(&iter)) {
+       BM_ITER_MESH (be, &iter, bm, BM_EDGES_OF_MESH) {
                bool is_cut = false;
                if (BM_elem_flag_test(be, BM_ELEM_SELECT)) {
                        const float *sco_a = screen_vert_coords[BM_elem_index_get(be->v1)];