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-04 20:36:31 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-04 20:36:31 +0400
commita0ab2eefb9c99140ebb3daad3be2303caea64b96 (patch)
tree406ed46881486425ada0baca05b67ed92d5bd01d /source/blender/bmesh
parent76e9f91d1c9ff5f026ff4e05e76b751f936f83f7 (diff)
* 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.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.c16
-rw-r--r--source/blender/bmesh/intern/bmesh_queries.h2
-rw-r--r--source/blender/bmesh/intern/bmesh_walkers_impl.c4
-rw-r--r--source/blender/bmesh/operators/bmo_edgesplit.c6
4 files changed, 15 insertions, 13 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c
index e78d577e067..986a60a221e 100644
--- a/source/blender/bmesh/intern/bmesh_queries.c
+++ b/source/blender/bmesh/intern/bmesh_queries.c
@@ -67,18 +67,20 @@ int BM_vert_in_edge(BMEdge *e, BMVert *v)
*
* 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 @@ BMLoop *BM_face_other_loop(BMFace *f, BMEdge *e, BMVert *v)
*
* 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 @@ BMLoop *BM_face_other_loop(BMFace *f, BMEdge *e, BMVert *v)
* | |
* +----------+
* v_prev --> v
- * ^^^^^^ ^ <-- These vert argumrnts define direction
+ * ^^^^^^ ^ <-- These vert args define direction
* in the face to check.
* The faces loop direction is ignored.
*
diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h
index bf340e5c4ec..6cad93d2658 100644
--- a/source/blender/bmesh/intern/bmesh_queries.h
+++ b/source/blender/bmesh/intern/bmesh_queries.h
@@ -39,7 +39,7 @@ int BM_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e);
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);
diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c
index 4f2682a7da9..5c9a6c032f7 100644
--- a/source/blender/bmesh/intern/bmesh_walkers_impl.c
+++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c
@@ -273,7 +273,7 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
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 @@ static void *bmw_LoopWalker_step(BMWalker *walker)
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;
diff --git a/source/blender/bmesh/operators/bmo_edgesplit.c b/source/blender/bmesh/operators/bmo_edgesplit.c
index 2b642a870cf..05a48f64e3b 100644
--- a/source/blender/bmesh/operators/bmo_edgesplit.c
+++ b/source/blender/bmesh/operators/bmo_edgesplit.c
@@ -180,7 +180,7 @@ static void tag_out_edges(BMesh *bm, EdgeTag *etags, BMOperator *UNUSED(op))
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 @@ void bmo_edgesplit_exec(BMesh *bm, BMOperator *op)
}
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 @@ void bmo_edgesplit_exec(BMesh *bm, BMOperator *op)
}
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));