[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44639] trunk/blender/source/blender: * rename BM_face_other_loop --> BM_face_other_edge_loop

Campbell Barton ideasman42 at gmail.com
Sun Mar 4 17:36:38 CET 2012


Revision: 44639
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44639
Author:   campbellbarton
Date:     2012-03-04 16:36:31 +0000 (Sun, 04 Mar 2012)
Log Message:
-----------
* rename BM_face_other_loop --> BM_face_other_edge_loop
* optimize BM_face_other_edge_loop to do about half as many iterations for quad heavy meshes, with ngons the gain is much more since searching around the entire ngon when the edge already stores its loop is silly.
 ... also nicer in cases where edge has no face users it avoids a loop on all face corners.

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_queries.c
    trunk/blender/source/blender/bmesh/intern/bmesh_queries.h
    trunk/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c
    trunk/blender/source/blender/bmesh/operators/bmo_edgesplit.c
    trunk/blender/source/blender/editors/mesh/bmesh_tools.c
    trunk/blender/source/blender/editors/mesh/loopcut.c
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/util/crazyspace.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_queries.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_queries.c	2012-03-04 16:01:02 UTC (rev 44638)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_queries.c	2012-03-04 16:36:31 UTC (rev 44639)
@@ -67,18 +67,20 @@
  *
  * Finds the other loop that shares \a v with \a e loop in \a f.
  */
-BMLoop *BM_face_other_loop(BMFace *f, BMEdge *e, BMVert *v)
+BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v)
 {
 	BMLoop *l_iter;
 	BMLoop *l_first;
 
-	l_iter = l_first = BM_FACE_FIRST_LOOP(f);
-	
+	/* we could loop around the face too, but turns out this uses a lot
+	 * more iterations (approx double with quads, many more with 5+ ngons) */
+	l_iter = l_first = e->l;
+
 	do {
-		if (l_iter->e == e) {
+		if (l_iter->e == e && l_iter->f == f) {
 			break;
 		}
-	} while ((l_iter = l_iter->next) != l_first);
+	} while ((l_iter = l_iter->radial_next) != l_first);
 	
 	return l_iter->v == v ? l_iter->prev : l_iter->next;
 }
@@ -88,7 +90,7 @@
  *
  * Finds the other loop in a face.
  *
- * This function returns a loop in \a f that shares an edge with \v
+ * This function returns a loop in \a f that shares an edge with \a v
  * The direction is defined by \a v_prev, where the return value is
  * the loop of what would be 'v_next'
  *
@@ -99,7 +101,7 @@
  *     |          |
  *     +----------+
  *     v_prev --> v
- *     ^^^^^^     ^ <-- These vert argumrnts define direction
+ *     ^^^^^^     ^ <-- These vert args define direction
  *                      in the face to check.
  *                      The faces loop direction is ignored.
  *

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_queries.h
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_queries.h	2012-03-04 16:01:02 UTC (rev 44638)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_queries.h	2012-03-04 16:36:31 UTC (rev 44639)
@@ -39,7 +39,7 @@
 
 int     BM_edge_face_pair(BMEdge *e, BMFace **r_fa, BMFace **r_fb);
 BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v);
-BMLoop *BM_face_other_loop(BMFace *f, BMEdge *e, BMVert *v);
+BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v);
 BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v);
 
 int     BM_vert_edge_count(BMVert *v);

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c	2012-03-04 16:01:02 UTC (rev 44638)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_walkers_impl.c	2012-03-04 16:36:31 UTC (rev 44639)
@@ -273,7 +273,7 @@
 	f = l->f;
 	
 	while (1) {
-		l = BM_face_other_loop(f, e, v);
+		l = BM_face_other_edge_loop(f, e, v);
 		if (l != l->radial_next) {
 			l = l->radial_next;
 			f = l->f;
@@ -474,7 +474,7 @@
 		while (1) {
 			if (rlen != 1 && i == stopi) break;
 
-			l = BM_face_other_loop(l->f, l->e, v);
+			l = BM_face_other_edge_loop(l->f, l->e, v);
 
 			if (!l)
 				break;

Modified: trunk/blender/source/blender/bmesh/operators/bmo_edgesplit.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_edgesplit.c	2012-03-04 16:01:02 UTC (rev 44638)
+++ trunk/blender/source/blender/bmesh/operators/bmo_edgesplit.c	2012-03-04 16:36:31 UTC (rev 44639)
@@ -180,7 +180,7 @@
 
 				startl = l;
 				do {
-					l = BM_face_other_loop(l->f, l->e, v);
+					l = BM_face_other_edge_loop(l->f, l->e, v);
 					if (l == startl || BM_edge_face_count(l->e) != 2) {
 						break;
 					}
@@ -317,7 +317,7 @@
 						}
 
 						l3 = l3->radial_next;
-						l3 = BM_face_other_loop(l3->f, l3->e, v);
+						l3 = BM_face_other_edge_loop(l3->f, l3->e, v);
 					} while (l3 != l2 && !BMO_elem_flag_test(bm, l3->e, EDGE_SEAM));
 
 					if (l3 == NULL || (BMO_elem_flag_test(bm, l3->e, EDGE_SEAM) && l3->e != l->e)) {
@@ -333,7 +333,7 @@
 								}
 
 								l3 = l3->radial_next;
-								l3 = BM_face_other_loop(l3->f, l3->e, v);
+								l3 = BM_face_other_edge_loop(l3->f, l3->e, v);
 								
 								et = &etags[BM_elem_index_get(l3->e)];
 							} while (l3 != l2 && !BMO_elem_flag_test(bm, l3->e, EDGE_SEAM));

Modified: trunk/blender/source/blender/editors/mesh/bmesh_tools.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/bmesh_tools.c	2012-03-04 16:01:02 UTC (rev 44638)
+++ trunk/blender/source/blender/editors/mesh/bmesh_tools.c	2012-03-04 16:36:31 UTC (rev 44639)
@@ -2398,12 +2398,12 @@
 		}
 		else if (BM_edge_face_count(e2) == 2) {
 			l = e2->l;
-			e = BM_face_other_loop(l->f, e2, v)->e;
+			e = BM_face_other_edge_loop(l->f, e2, v)->e;
 			BM_elem_flag_enable(e, BM_ELEM_TAG);
 			BM_elem_select_set(bm, e, TRUE);
 			
 			l = e2->l->radial_next;
-			e = BM_face_other_loop(l->f, e2, v)->e;
+			e = BM_face_other_edge_loop(l->f, e2, v)->e;
 			BM_elem_flag_enable(e, BM_ELEM_TAG);
 			BM_elem_select_set(bm, e, TRUE);
 		}
@@ -2423,9 +2423,9 @@
 			}
 			
 			if (i == 1 && e2->l) {
-				l = BM_face_other_loop(e2->l->f, e2, v);
+				l = BM_face_other_edge_loop(e2->l->f, e2, v);
 				l = l->radial_next;
-				l = BM_face_other_loop(l->f, l->e, v);
+				l = BM_face_other_edge_loop(l->f, l->e, v);
 
 				if (l) {
 					BM_elem_select_set(bm, l->e, TRUE);

Modified: trunk/blender/source/blender/editors/mesh/loopcut.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/loopcut.c	2012-03-04 16:01:02 UTC (rev 44638)
+++ trunk/blender/source/blender/editors/mesh/loopcut.c	2012-03-04 16:36:31 UTC (rev 44639)
@@ -161,7 +161,7 @@
 		return;
 	}
 	
-	l2 = BM_face_other_loop(l->f, l->e, eed->v1);
+	l2 = BM_face_other_edge_loop(l->f, l->e, eed->v1);
 	rev = (l2 == l->prev);
 	while (l2->v != lasteed->v1 && l2->v != lasteed->v2) {
 		l2 = rev ? l2->prev : l2->next;

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c	2012-03-04 16:01:02 UTC (rev 44638)
+++ trunk/blender/source/blender/editors/transform/transform.c	2012-03-04 16:36:31 UTC (rev 44639)
@@ -4310,7 +4310,7 @@
 
 	firstl = l;
 	do {
-		l = BM_face_other_loop(l->f, l->e, v);
+		l = BM_face_other_edge_loop(l->f, l->e, v);
 		if (l->radial_next == l)
 			return NULL;
 		
@@ -4339,12 +4339,12 @@
 			i += 1;
 		}
 
-		if (BM_face_other_loop(l->f, l->e, v)->e == nexte) {
+		if (BM_face_other_edge_loop(l->f, l->e, v)->e == nexte) {
 			if (i)
 				mul_v3_fl(a, 1.0f / (float)i);
 			
 			copy_v3_v3(vec, a);
-			return BM_face_other_loop(l->f, l->e, v);
+			return BM_face_other_edge_loop(l->f, l->e, v);
 		}
 		
 		l = l->radial_next;
@@ -4477,11 +4477,11 @@
 		l1 = e->l;
 		l2 = e->l->radial_next;
 
-		l = BM_face_other_loop(l1->f, l1->e, v);
+		l = BM_face_other_edge_loop(l1->f, l1->e, v);
 		sub_v3_v3v3(vec, BM_edge_other_vert(l->e, v)->co, v->co);
 
 		if (l2 != l1) {
-			l = BM_face_other_loop(l2->f, l2->e, v);
+			l = BM_face_other_edge_loop(l2->f, l2->e, v);
 			sub_v3_v3v3(vec2, BM_edge_other_vert(l->e, v)->co, v->co);
 		} else {
 			l2 = NULL;
@@ -4498,11 +4498,11 @@
 			if (l2)
 				copy_v3_v3(sv->downvec, vec2);
 
-			l = BM_face_other_loop(l1->f, l1->e, v);
+			l = BM_face_other_edge_loop(l1->f, l1->e, v);
 			sv->up = BM_edge_other_vert(l->e, v);
 
 			if (l2) {
-				l = BM_face_other_loop(l2->f, l2->e, v);
+				l = BM_face_other_edge_loop(l2->f, l2->e, v);
 				sv->down = BM_edge_other_vert(l->e, v);
 			}
 
@@ -4517,12 +4517,12 @@
 				sv->v = v;
 				sv->origvert = *v;
 				
-				l = BM_face_other_loop(l1->f, l1->e, v);
+				l = BM_face_other_edge_loop(l1->f, l1->e, v);
 				sv->up = BM_edge_other_vert(l->e, v);
 				sub_v3_v3v3(sv->upvec, BM_edge_other_vert(l->e, v)->co, v->co);
 
 				if (l2) {
-					l = BM_face_other_loop(l2->f, l2->e, v);
+					l = BM_face_other_edge_loop(l2->f, l2->e, v);
 					sv->down = BM_edge_other_vert(l->e, v);
 					sub_v3_v3v3(sv->downvec, BM_edge_other_vert(l->e, v)->co, v->co);
 				}

Modified: trunk/blender/source/blender/editors/util/crazyspace.c
===================================================================
--- trunk/blender/source/blender/editors/util/crazyspace.c	2012-03-04 16:01:02 UTC (rev 44638)
+++ trunk/blender/source/blender/editors/util/crazyspace.c	2012-03-04 16:36:31 UTC (rev 44639)
@@ -153,7 +153,7 @@
 			continue;
 		
 		BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_VERT, v) {
-			BMLoop *l2 = BM_face_other_loop(l->f, l->e, v);
+			BMLoop *l2 = BM_face_other_edge_loop(l->f, l->e, v);
 			
 			/* retrieve mapped coordinates */
 			v1= mappedcos + 3*BM_elem_index_get(l->v);




More information about the Bf-blender-cvs mailing list