Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2012-03-13 21:13:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-13 21:13:44 +0400
commitb47e2ee907a7cc4c949a6a6e4dc895532ca53f5e (patch)
treecb8f5976cad56b2ea54dd6bd4417364eec145483 /source/blender/bmesh
parent1581816d549c148b80eff6cae7234b41966af85a (diff)
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.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c98
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_private.h1
2 files changed, 50 insertions, 49 deletions
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index 23d82f0ab34..3c8e2c1f974 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -396,7 +396,6 @@ static void bmw_LoopWalker_begin(BMWalker *walker, void *data)
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_yield(BMWalker *walker)
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 @@ static void *bmw_LoopWalker_step(BMWalker *walker)
}
}
}
-
- 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 = l2;
- i += 1;
+ l = l_next;
+ i++;
+ }
+ }
}
- }
- 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);
+ }
+ }
}
}
diff --git a/source/blender/bmesh/intern/bmesh_walkers_private.h b/source/blender/bmesh/intern/bmesh_walkers_private.h
index d51a3b3ddb1..d8eccda2063 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_private.h
+++ b/source/blender/bmesh/intern/bmesh_walkers_private.h
@@ -61,7 +61,6 @@ typedef struct BMwLoopWalker {
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;