code cleanup: use BMW_begin insode for loops body.
authorCampbell Barton <ideasman42@gmail.com>
Mon, 14 Jan 2013 09:53:56 +0000 (09:53 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 14 Jan 2013 09:53:56 +0000 (09:53 +0000)
doc/python_api/examples/bpy.types.AddonPreferences.1.py
source/blender/bmesh/intern/bmesh_walkers.h
source/blender/bmesh/operators/bmo_dissolve.c
source/blender/bmesh/operators/bmo_removedoubles.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/mesh/editmesh_select.c
source/blender/editors/mesh/editmesh_tools.c

index 08de6f4..73f90ac 100644 (file)
@@ -17,6 +17,8 @@ from bpy.props import StringProperty, IntProperty, BoolProperty
 
 
 class ExampleAddonPreferences(AddonPreferences):
+    # this must match the addon name, use '__package__'
+    # when defining this in a submodule of a python package.
     bl_idname = __name__
 
     filepath = StringProperty(
index 4f81f38..8be362b 100644 (file)
@@ -100,10 +100,9 @@ void  BMW_reset(BMWalker *walker);
  * BMFace *f;
  *
  * BMW_init(&walker, bm, BMW_ISLAND, SOME_OP_FLAG);
- * f = BMW_begin(&walker, some_start_face);
- * for (; f; f = BMW_step(&walker))
- * {
- *     //do something with f
+ *
+ * for (f = BMW_begin(&walker, some_start_face); f; f = BMW_step(&walker)) {
+ *     // do something with f
  * }
  * BMW_end(&walker);
  */
index 7c3bcd6..d23c6d7 100644 (file)
@@ -55,10 +55,8 @@ static int UNUSED_FUNCTION(check_hole_in_region) (BMesh * bm, BMFace * f)
                 BMW_FLAG_NOP,
                 BMW_NIL_LAY);
 
-       f2 = BMW_begin(&regwalker, f);
-       for ( ; f2; f2 = BMW_step(&regwalker)) {
-               l2 = BM_iter_new(&liter2, bm, BM_LOOPS_OF_FACE, f2);
-               for ( ; l2; l2 = BM_iter_step(&liter2)) {
+       for (f2 = BMW_begin(&regwalker, f); f2; f2 = BMW_step(&regwalker)) {
+               BM_ITER_ELEM (l2, &liter2, f2, BM_LOOPS_OF_FACE) {
                        l3 = l2->radial_next;
                        if (BMO_elem_flag_test(bm, l3->f, FACE_MARK) !=
                            BMO_elem_flag_test(bm, l2->f, FACE_MARK))
@@ -115,8 +113,7 @@ void bmo_dissolve_faces_exec(BMesh *bm, BMOperator *op)
                         BMW_FLAG_NOP, /* no need to check BMW_FLAG_TEST_HIDDEN, faces are already marked by the bmo */
                         BMW_NIL_LAY);
 
-               f2 = BMW_begin(&regwalker, f);
-               for ( ; f2; f2 = BMW_step(&regwalker)) {
+               for (f2 = BMW_begin(&regwalker, f); f2; f2 = BMW_step(&regwalker)) {
                        BLI_array_append(faces, f2);
                }
                BMW_end(&regwalker);
index 87e26f1..2f7011e 100644 (file)
@@ -394,11 +394,10 @@ void bmo_collapse_exec(BMesh *bm, BMOperator *op)
                if (!BMO_elem_flag_test(bm, e, EDGE_MARK))
                        continue;
 
-               e = BMW_begin(&walker, e->v1);
                BLI_array_empty(edges);
 
                INIT_MINMAX(min, max);
-               for (tot = 0; e; tot++, e = BMW_step(&walker)) {
+               for (e = BMW_begin(&walker, e->v1), tot = 0; e; e = BMW_step(&walker), tot++) {
                        BLI_array_grow_one(edges);
                        edges[tot] = e;
 
@@ -454,11 +453,9 @@ static void bmo_collapsecon_do_layer(BMesh *bm, BMOperator *op, int layer)
                        if (BMO_elem_flag_test(bm, l->e, EDGE_MARK)) {
                                /* walk */
                                BLI_array_empty(blocks);
-                               tot = 0;
-                               l2 = BMW_begin(&walker, l);
 
                                CustomData_data_initminmax(type, &min, &max);
-                               for (tot = 0; l2; tot++, l2 = BMW_step(&walker)) {
+                               for (l2 = BMW_begin(&walker, l), tot = 0; l2; l2 = BMW_step(&walker), tot++) {
                                        BLI_array_grow_one(blocks);
                                        blocks[tot] = CustomData_bmesh_get_layer_n(&bm->ldata, l2->head.data, layer);
                                        CustomData_data_dominmax(type, blocks[tot], &min, &max);
index 5f923dd..93090a2 100644 (file)
@@ -154,9 +154,9 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed,
 static void edgering_sel(RingSelOpData *lcd, int previewlines, int select)
 {
        BMEditMesh *em = lcd->em;
-       BMEdge *startedge = lcd->eed;
-       BMEdge *eed, *lasteed;
-       BMVert *v[2][2], *lastv1;
+       BMEdge *eed_start = lcd->eed;
+       BMEdge *eed, *eed_last;
+       BMVert *v[2][2], *v_last;
        BMWalker walker;
        float (*edges)[2][3] = NULL;
        BLI_array_declare(edges);
@@ -164,7 +164,7 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select)
        
        memset(v, 0, sizeof(v));
        
-       if (!startedge)
+       if (!eed_start)
                return;
 
        if (lcd->edges) {
@@ -183,8 +183,7 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select)
                         BMW_FLAG_TEST_HIDDEN,
                         BMW_NIL_LAY);
 
-               eed = BMW_begin(&walker, startedge);
-               for ( ; eed; eed = BMW_step(&walker)) {
+               for (eed = BMW_begin(&walker, eed_start); eed; eed = BMW_step(&walker)) {
                        BM_edge_select_set(em->bm, eed, TRUE);
                }
                BMW_end(&walker);
@@ -197,22 +196,23 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select)
                 BMW_FLAG_TEST_HIDDEN,
                 BMW_NIL_LAY);
 
-       eed = startedge = BMW_begin(&walker, startedge);
-       lastv1 = NULL;
-       for (lasteed = NULL; eed; eed = BMW_step(&walker)) {
-               if (lasteed) {
-                       if (lastv1) {
+       v_last   = NULL;
+       eed_last = NULL;
+
+       for (eed = eed_start = BMW_begin(&walker, eed_start); eed; eed = BMW_step(&walker)) {
+               if (eed_last) {
+                       if (v_last) {
                                v[1][0] = v[0][0];
                                v[1][1] = v[0][1];
                        }
                        else {
-                               v[1][0] = lasteed->v1;
-                               v[1][1] = lasteed->v2;
-                               lastv1 = lasteed->v1;
+                               v[1][0] = eed_last->v1;
+                               v[1][1] = eed_last->v2;
+                               v_last  = eed_last->v1;
                        }
 
-                       edgering_find_order(lasteed, eed, lastv1, v);
-                       lastv1 = v[0][0];
+                       edgering_find_order(eed_last, eed, v_last, v);
+                       v_last = v[0][0];
 
                        BLI_array_grow_items(edges, previewlines);
 
@@ -223,18 +223,18 @@ static void edgering_sel(RingSelOpData *lcd, int previewlines, int select)
                                tot++;
                        }
                }
-               lasteed = eed;
+               eed_last = eed;
        }
        
 #ifdef BMW_EDGERING_NGON
        if (lasteed != startedge && BM_edge_share_face_check(lasteed, startedge)) {
 #else
-       if (lasteed != startedge && BM_edge_share_quad_check(lasteed, startedge)) {
+       if (eed_last != eed_start && BM_edge_share_quad_check(eed_last, eed_start)) {
 #endif
                v[1][0] = v[0][0];
                v[1][1] = v[0][1];
 
-               edgering_find_order(lasteed, startedge, lastv1, v);
+               edgering_find_order(eed_last, eed_start, v_last, v);
                
                BLI_array_grow_items(edges, previewlines);
 
index d727caf..e856498 100644 (file)
@@ -985,8 +985,8 @@ static void walker_select(BMEditMesh *em, int walkercode, void *start, int selec
                 BMW_MASK_NOP, BMW_MASK_NOP, BMW_MASK_NOP,
                 BMW_FLAG_TEST_HIDDEN,
                 BMW_NIL_LAY);
-       ele = BMW_begin(&walker, start);
-       for (; ele; ele = BMW_step(&walker)) {
+
+       for (ele = BMW_begin(&walker, start); ele; ele = BMW_step(&walker)) {
                if (!select) {
                        BM_select_history_remove(bm, ele);
                }
@@ -2262,8 +2262,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *
                         BMW_FLAG_TEST_HIDDEN,
                         BMW_NIL_LAY);
 
-               efa = BMW_begin(&walker, efa);
-               for (; efa; efa = BMW_step(&walker)) {
+               for (efa = BMW_begin(&walker, efa); efa; efa = BMW_step(&walker)) {
                        BM_face_select_set(bm, efa, sel);
                }
                BMW_end(&walker);
@@ -2284,8 +2283,7 @@ static int edbm_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *
                         BMW_FLAG_TEST_HIDDEN,
                         BMW_NIL_LAY);
 
-               e = BMW_begin(&walker, eed->v1);
-               for (; e; e = BMW_step(&walker)) {
+               for (e = BMW_begin(&walker, eed->v1); e; e = BMW_step(&walker)) {
                        BM_edge_select_set(bm, e, sel);
                }
                BMW_end(&walker);
@@ -2356,8 +2354,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op)
 
                BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) {
                        if (BM_elem_flag_test(efa, BM_ELEM_TAG)) {
-                               efa = BMW_begin(&walker, efa);
-                               for (; efa; efa = BMW_step(&walker)) {
+                               for (efa = BMW_begin(&walker, efa); efa; efa = BMW_step(&walker)) {
                                        BM_face_select_set(bm, efa, TRUE);
                                }
                        }
@@ -2385,8 +2382,7 @@ static int edbm_select_linked_exec(bContext *C, wmOperator *op)
 
                BM_ITER_MESH (v, &iter, em->bm, BM_VERTS_OF_MESH) {
                        if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
-                               e = BMW_begin(&walker, v);
-                               for (; e; e = BMW_step(&walker)) {
+                               for (e = BMW_begin(&walker, v); e; e = BMW_step(&walker)) {
                                        BM_edge_select_set(em->bm, e, true);
                                }
                        }
index 951c8b4..1cf62ab 100644 (file)
@@ -3190,8 +3190,7 @@ static int mesh_separate_loose(Main *bmain, Scene *scene, Base *base_old, BMesh
                         BMW_FLAG_NOP,
                         BMW_NIL_LAY);
 
-               e = BMW_begin(&walker, v_seed);
-               for (; e; e = BMW_step(&walker)) {
+               for (e = BMW_begin(&walker, v_seed); e; e = BMW_step(&walker)) {
                        if (!BM_elem_flag_test(e->v1, BM_ELEM_TAG)) { BM_elem_flag_enable(e->v1, BM_ELEM_TAG); tot++; }
                        if (!BM_elem_flag_test(e->v2, BM_ELEM_TAG)) { BM_elem_flag_enable(e->v2, BM_ELEM_TAG); tot++; }
                }