[Bf-blender-cvs] [ed225d4] master: BMesh: avoid verts-of-edge iterator

Campbell Barton noreply at git.blender.org
Tue Jun 21 00:08:24 CEST 2016


Commit: ed225d4517c151e8ad0aa30a61daf46f9982f298
Author: Campbell Barton
Date:   Tue Jun 21 07:50:19 2016 +1000
Branches: master
https://developer.blender.org/rBed225d4517c151e8ad0aa30a61daf46f9982f298

BMesh: avoid verts-of-edge iterator

Since this function is called a lot, loop over data directly.

===================================================================

M	source/blender/bmesh/intern/bmesh_polygon_edgenet.c

===================================================================

diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.c b/source/blender/bmesh/intern/bmesh_polygon_edgenet.c
index c224a1a..009df44 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) {




More information about the Bf-blender-cvs mailing list