Revision: 44852
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44852
Author:   campbellbarton
Date:     2012-03-13 17:13:44 +0000 (Tue, 13 Mar 2012)
Log Message:
-----------
code/style cleanup for loop walker which was is fairly confusing and hard to 
extend.
- only have one return at the end of the function.
- break up functionality more clearly between wire/face walk.
- remove unused struct member.

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c
    trunk/blender/source/blender/bmesh/intern/bmesh_walkers_private.h

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c      
2012-03-13 15:44:48 UTC (rev 44851)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c      
2012-03-13 17:13:44 UTC (rev 44852)
@@ -396,7 +396,6 @@
 
        lwalk->cur = lwalk->start = e;
        lwalk->lastv = lwalk->startv = v;
-       lwalk->stage2 = 0;
        lwalk->is_boundry = BM_edge_is_boundary(e);
        lwalk->is_single = (BM_vert_edge_count_nonwire(e->v1) == 2 &&
                            BM_vert_edge_count_nonwire(e->v2) == 2);
@@ -427,21 +426,18 @@
 static void *bmw_LoopWalker_step(BMWalker *walker)
 {
        BMwLoopWalker *lwalk = BMW_current_state(walker), owalk;
-       BMIter eiter;
        BMEdge *e = lwalk->cur, *nexte = NULL;
-       BMLoop *l, *l2;
+       BMLoop *l;
        BMVert *v;
-       int vert_edge_tot;
-       int i = 0, stopi;
-       /* int found = 0; */ /* UNUSED */
+       int i;
 
        owalk = *lwalk;
        BMW_state_remove(walker);
 
        l = e->l;
 
-       /* handle wire edge case */
-       if (!l) {
+       if (!l) { /* WIRE EDGE */
+               BMIter eiter;
 
                /* match trunk: mark all connected wire edges */
                for (i = 0; i < 2; i++) {
@@ -459,60 +455,66 @@
                                }
                        }
                }
-
-               return owalk.cur;
        }
+       else {  /* FACE EDGE */
+               int vert_edge_tot;
+               int stopi;
 
-       v = BM_edge_other_vert(e, lwalk->lastv);
+               v = BM_edge_other_vert(e, lwalk->lastv);
 
-       vert_edge_tot = BM_vert_edge_count_nonwire(v);
+               vert_edge_tot = BM_vert_edge_count_nonwire(v);
 
-       if (/* check if we should step, this is fairly involved */
+               if (/* check if we should step, this is fairly involved */
 
-           /* typical loopiong over edges in the middle of a mesh */
-           /* however, why use 2 here at all? I guess for internal ngon loops 
it can be useful. Antony R. */
-           ((vert_edge_tot == 4 || vert_edge_tot == 2) && owalk.is_boundry == 
FALSE) ||
+                       /* typical loopiong over edges in the middle of a mesh 
*/
+                       /* however, why use 2 here at all? I guess for internal 
ngon loops it can be useful. Antony R. */
+                       ((vert_edge_tot == 4 || vert_edge_tot == 2) && 
owalk.is_boundry == FALSE) ||
 
-           /* walk over boundry of faces but stop at corners */
-           (owalk.is_boundry == TRUE && owalk.is_single  == FALSE && 
vert_edge_tot > 2) ||
+                       /* walk over boundry of faces but stop at corners */
+                       (owalk.is_boundry == TRUE && owalk.is_single  == FALSE 
&& vert_edge_tot > 2) ||
 
-           /* initial edge was a boundry, so is this edge and vertex is only 
apart of this face
-            * this lets us walk over the the boundry of an ngon which is handy 
*/
-           (owalk.is_boundry == TRUE && owalk.is_single == TRUE && 
vert_edge_tot == 2 && BM_edge_is_boundary(e)))
-       {
-               i = 0;
-               stopi = vert_edge_tot / 2;
-               while (1) {
-                       if (owalk.is_boundry == FALSE && i == stopi) break;
+                       /* initial edge was a boundry, so is this edge and 
vertex is only apart of this face
+                        * this lets us walk over the the boundry of an ngon 
which is handy */
+                       (owalk.is_boundry == TRUE && owalk.is_single == TRUE && 
vert_edge_tot == 2 && BM_edge_is_boundary(e)))
+               {
+                       i = 0;
+                       stopi = vert_edge_tot / 2;
+                       while (1) {
+                               if ((owalk.is_boundry == FALSE) && (i == 
stopi)) {
+                                       break;
+                               }
 
-                       l = BM_face_other_edge_loop(l->f, l->e, v);
+                               l = BM_face_other_edge_loop(l->f, l->e, v);
 
-                       if (!l)
-                               break;
+                               if (l == NULL) {
+                                       break;
+                               }
+                               else {
+                                       BMLoop *l_next;
 
-                       l2 = l->radial_next;
+                                       l_next = l->radial_next;
 
-                       if (l2 == l || !l2) {
-                               break;
+                                       if ((l_next == l) || (l_next == NULL)) {
+                                               break;
+                                       }
+
+                                       l = l_next;
+                                       i++;
+                               }
                        }
-
-                       l = l2;
-                       i += 1;
                }
-       }
 
-       if (!l) {
-               return owalk.cur;
-       }
-
-       if (l != e->l && !BLI_ghash_haskey(walker->visithash, l->e)) {
-               if (!(owalk.is_boundry == FALSE && i != stopi)) {
-                       lwalk = BMW_state_add(walker);
-                       lwalk->cur = l->e;
-                       lwalk->lastv = v;
-                       lwalk->is_boundry = owalk.is_boundry;
-                       lwalk->is_single = owalk.is_single;
-                       BLI_ghash_insert(walker->visithash, l->e, NULL);
+               if (l != NULL) {
+                       if (l != e->l && !BLI_ghash_haskey(walker->visithash, 
l->e)) {
+                               if (!(owalk.is_boundry == FALSE && i != stopi)) 
{
+                                       lwalk = BMW_state_add(walker);
+                                       lwalk->cur = l->e;
+                                       lwalk->lastv = v;
+                                       lwalk->is_boundry = owalk.is_boundry;
+                                       lwalk->is_single = owalk.is_single;
+                                       BLI_ghash_insert(walker->visithash, 
l->e, NULL);
+                               }
+                       }
                }
        }
 

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_walkers_private.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_walkers_private.h   
2012-03-13 15:44:48 UTC (rev 44851)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_walkers_private.h   
2012-03-13 17:13:44 UTC (rev 44852)
@@ -61,7 +61,6 @@
        BMwGenericWalker header;
        BMEdge *cur, *start;
        BMVert *lastv, *startv;
-       int stage2;
        short is_boundry; /* boundry looping changes behavior */
        short is_single;  /* single means the edge verts are only connected to 
1 face */
 } BMwLoopWalker;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to