diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-06-21 00:50:19 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-06-21 01:10:51 +0300 |
commit | ed225d4517c151e8ad0aa30a61daf46f9982f298 (patch) | |
tree | 2289d4f51d75bd8f02498433328706eca0917a45 /source/blender/bmesh | |
parent | dfa7ddd4a8d12a2586c23ae3cb986286f32c9503 (diff) |
BMesh: avoid verts-of-edge iterator
Since this function is called a lot, loop over data directly.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_polygon_edgenet.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c index c224a1ad587..009df44b1da 100644 --- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c +++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c @@ -104,8 +104,6 @@ static bool bm_face_split_edgenet_find_loop_pair( /* Always find one boundary edge (to determine winding) * and one wire (if available), otherwise another boundary. */ - BMIter iter; - BMEdge *e; /* detect winding */ BMLoop *l_walk; @@ -116,18 +114,22 @@ static bool bm_face_split_edgenet_find_loop_pair( int edges_boundary_len = 0; int edges_wire_len = 0; - BM_ITER_ELEM (e, &iter, v_init, BM_EDGES_OF_VERT) { - if (BM_ELEM_API_FLAG_TEST(e, EDGE_NET)) { - const unsigned int count = bm_edge_flagged_radial_count(e); - if (count == 1) { - BLI_SMALLSTACK_PUSH(edges_boundary, e); - edges_boundary_len++; - } - else if (count == 0) { - BLI_SMALLSTACK_PUSH(edges_wire, e); - edges_wire_len++; + { + BMEdge *e, *e_first; + e = e_first = v_init->e; + do { + if (BM_ELEM_API_FLAG_TEST(e, EDGE_NET)) { + const unsigned int count = bm_edge_flagged_radial_count(e); + if (count == 1) { + BLI_SMALLSTACK_PUSH(edges_boundary, e); + edges_boundary_len++; + } + else if (count == 0) { + BLI_SMALLSTACK_PUSH(edges_wire, e); + edges_wire_len++; + } } - } + } while ((e = BM_DISK_EDGE_NEXT(e, v_init)) != e_first); } /* first edge should always be boundary */ @@ -157,6 +159,7 @@ static bool bm_face_split_edgenet_find_loop_pair( v_next = BM_edge_other_vert(e_pair[1], v_init); angle_best = angle_on_axis_v3v3v3_v3(v_prev->co, v_init->co, v_next->co, face_normal); + BMEdge *e; while ((e = BLI_SMALLSTACK_POP(edges_wire))) { float angle_test; v_next = BM_edge_other_vert(e, v_init); @@ -232,9 +235,6 @@ static bool bm_face_split_edgenet_find_loop_walk( * alternatives are stored in the 'vert_stack'. */ while ((v = BLI_SMALLSTACK_POP_EX(vert_stack, vert_stack_next))) { - BMIter eiter; - BMEdge *e_next; - #ifdef USE_FASTPATH_NOFORK walk_nofork: #else @@ -250,9 +250,12 @@ walk_nofork: goto finally; } - BM_ITER_ELEM (e_next, &eiter, v, BM_EDGES_OF_VERT) { - if ((v->e != e_next) && - (BM_ELEM_API_FLAG_TEST(e_next, EDGE_NET)) && + BMEdge *e_next, *e_first; + e_first = v->e; + e_next = BM_DISK_EDGE_NEXT(e_first, v); /* always skip this verts edge */ + do { + BLI_assert(v->e != e_next); + if ((BM_ELEM_API_FLAG_TEST(e_next, EDGE_NET)) && (bm_edge_flagged_radial_count(e_next) < 2)) { BMVert *v_next; @@ -279,7 +282,7 @@ walk_nofork: v_next->e = e_next; } } - } + } while ((e_next = BM_DISK_EDGE_NEXT(e_next, v)) != e_first); #ifdef USE_FASTPATH_NOFORK if (STACK_SIZE(edge_order) == 1) { |