simple optimization, replace BM_face_other_edge_loop() with BM_loop_other_edge_loop...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 19 Apr 2013 01:02:58 +0000 (01:02 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 19 Apr 2013 01:02:58 +0000 (01:02 +0000)
source/blender/bmesh/intern/bmesh_queries.c
source/blender/bmesh/intern/bmesh_queries.h
source/blender/bmesh/intern/bmesh_walkers_impl.c
source/blender/editors/mesh/editmesh_loopcut.c
source/blender/editors/mesh/editmesh_rip.c
source/blender/editors/transform/transform.c
source/blender/editors/util/crazyspace.c

index c0db2c0a19e1cd376c6d83561af831a783173c78..f61c63ee6c52dff8a2d70b22add6d0c2f490808f 100644 (file)
@@ -63,23 +63,24 @@ bool BM_vert_in_edge(const BMEdge *e, const BMVert *v)
  *                      in the face to check.
  *                      The faces loop direction is ignored.
  * </pre>
+ *
+ * \note caller must ensure \a e is used in \a f
  */
 BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v)
 {
-       BMLoop *l_iter;
-       BMLoop *l_first;
-
-       /* 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;
+       BMLoop *l = BM_face_edge_share_loop(f, e);
+       BLI_assert(l != NULL);
+       return BM_loop_other_edge_loop(l, v);
+}
 
-       do {
-               if (l_iter->e == e && l_iter->f == f) {
-                       break;
-               }
-       } while ((l_iter = l_iter->radial_next) != l_first);
-       
-       return l_iter->v == v ? l_iter->prev : l_iter->next;
+/**
+ * See #BM_face_other_edge_loop This is the same functionality
+ * to be used when the edges loop is already known.
+ */
+BMLoop *BM_loop_other_edge_loop(BMLoop *l, BMVert *v)
+{
+       BLI_assert(BM_vert_in_edge(l->e, v));
+       return l->v == v ? l->prev : l->next;
 }
 
 /**
index ec52a7af1626413ebcb3cfc9239d477520905072..3d3e1a3d9d905779247abd0ab551b6999a0fb17e 100644 (file)
@@ -44,6 +44,7 @@ bool    BM_edge_loop_pair(BMEdge *e, BMLoop **r_la, BMLoop **r_lb);
 BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v);
 BMLoop *BM_edge_other_loop(BMEdge *e, BMLoop *l);
 BMLoop *BM_face_other_edge_loop(BMFace *f, BMEdge *e, BMVert *v);
+BMLoop *BM_loop_other_edge_loop(BMLoop *l, BMVert *v);
 BMLoop *BM_face_other_vert_loop(BMFace *f, BMVert *v_prev, BMVert *v);
 BMLoop *BM_loop_other_vert_loop(BMLoop *l, BMVert *v);
 BMLoop *BM_vert_step_fan_loop(BMLoop *l, BMEdge **e_step);
index a50b708961cf764518480c3d364c8fd6d1c733ed..55d9153fd6304c5d992c1accea8733d459a1494d 100644 (file)
@@ -313,7 +313,7 @@ static void *bmw_IslandboundWalker_step(BMWalker *walker)
        f = l->f;
        
        while (1) {
-               l = BM_face_other_edge_loop(f, e, v);
+               l = BM_loop_other_edge_loop(l, v);
                if (l != l->radial_next) {
                        l = l->radial_next;
                        f = l->f;
@@ -564,7 +564,7 @@ static void *bmw_LoopWalker_step(BMWalker *walker)
                                        break;
                                }
 
-                               l = BM_face_other_edge_loop(l->f, l->e, v);
+                               l = BM_loop_other_edge_loop(l, v);
 
                                if (l == NULL) {
                                        break;
index 1bd6f285706a93d0c6bd54accaac71a5fd997027..626f372c661371c9b54ac0fdfd04828b3a57a84a 100644 (file)
@@ -137,7 +137,7 @@ static void edgering_find_order(BMEdge *lasteed, BMEdge *eed,
                return;
        }
        
-       l2 = BM_face_other_edge_loop(l->f, l->e, eed->v1);
+       l2 = BM_loop_other_edge_loop(l, eed->v1);
        rev = (l2 == l->prev);
        while (l2->v != lasteed->v1 && l2->v != lasteed->v2) {
                l2 = rev ? l2->prev : l2->next;
index b4c31b2df912cba883d9370f7071919cd4bcf01d..c9e248e575dcc9e3027ceaf01f47981f7d4caee3 100644 (file)
@@ -770,11 +770,11 @@ static int edbm_rip_invoke__vert(bContext *C, wmOperator *op, const wmEvent *eve
        else {
                if (BM_edge_is_manifold(e2)) {
                        l = e2->l;
-                       e = BM_face_other_edge_loop(l->f, e2, v)->e;
+                       e = BM_loop_other_edge_loop(l, v)->e;
                        BM_elem_flag_enable(e, BM_ELEM_TAG);
 
                        l = e2->l->radial_next;
-                       e = BM_face_other_edge_loop(l->f, e2, v)->e;
+                       e = BM_loop_other_edge_loop(l, v)->e;
                        BM_elem_flag_enable(e, BM_ELEM_TAG);
                }
                else {
@@ -920,14 +920,14 @@ static int edbm_rip_invoke__edge(bContext *C, wmOperator *op, const wmEvent *eve
                                l = (edbm_rip_edge_side_measure(e2, l_a, ar, projectMat, fmval) <
                                     edbm_rip_edge_side_measure(e2, l_b, ar, projectMat, fmval)) ? l_a : l_b;
 
-                               l = BM_face_other_edge_loop(l->f, e2, v);
+                               l = BM_loop_other_edge_loop(l, v);
                                /* important edge is manifold else we can be attempting to split off a fan that don't budge,
                                 * not crashing but adds duplicate edge. */
                                if (BM_edge_is_manifold(l->e)) {
                                        l = l->radial_next;
 
                                        if (totedge_manifold != 3)
-                                               l = BM_face_other_edge_loop(l->f, l->e, v);
+                                               l = BM_loop_other_edge_loop(l, v);
 
                                        if (l) {
                                                BLI_assert(!BM_elem_flag_test(l->e, BM_ELEM_TAG));
index ca73405fb168c0c63a06d3445fa71d01e35a5272..2bc587d8f7315b90f3bd5187c34694c597e5795e 100644 (file)
@@ -5017,7 +5017,7 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
 
        l_first = l;
        do {
-               l = BM_face_other_edge_loop(l->f, l->e, v);
+               l = BM_loop_other_edge_loop(l, v);
                if (l->radial_next == l)
                        return NULL;
                
@@ -5077,13 +5077,13 @@ static BMLoop *get_next_loop(BMVert *v, BMLoop *l,
                        i += 1;
                }
 
-               if (BM_face_other_edge_loop(l->f, l->e, v)->e == e_next) {
+               if (BM_loop_other_edge_loop(l, v)->e == e_next) {
                        if (i) {
                                len_v3_ensure(vec_accum, vec_accum_len / (float)i);
                        }
 
                        copy_v3_v3(r_slide_vec, vec_accum);
-                       return BM_face_other_edge_loop(l->f, l->e, v);
+                       return BM_loop_other_edge_loop(l, v);
                }
                
                BLI_assert(l != l->radial_next);
@@ -5301,11 +5301,11 @@ static int createEdgeSlideVerts(TransInfo *t)
                l1 = e->l;
                l2 = e->l->radial_next;
 
-               l = BM_face_other_edge_loop(l1->f, l1->e, v);
+               l = BM_loop_other_edge_loop(l1, v);
                sub_v3_v3v3(vec, BM_edge_other_vert(l->e, v)->co, v->co);
 
                if (l2 != l1) {
-                       l = BM_face_other_edge_loop(l2->f, l2->e, v);
+                       l = BM_loop_other_edge_loop(l2, v);
                        sub_v3_v3v3(vec2, BM_edge_other_vert(l->e, v)->co, v->co);
                }
                else {
@@ -5328,11 +5328,11 @@ static int createEdgeSlideVerts(TransInfo *t)
                        if (l2)
                                copy_v3_v3(sv->downvec, vec2);
 
-                       l = BM_face_other_edge_loop(l1->f, l1->e, v);
+                       l = BM_loop_other_edge_loop(l1, v);
                        sv->up = BM_edge_other_vert(l->e, v);
 
                        if (l2) {
-                               l = BM_face_other_edge_loop(l2->f, l2->e, v);
+                               l = BM_loop_other_edge_loop(l2, v);
                                sv->down = BM_edge_other_vert(l->e, v);
                        }
 
@@ -5347,12 +5347,12 @@ static int createEdgeSlideVerts(TransInfo *t)
                                sv->origvert = *v;
                                sv->loop_nr = loop_nr;
                                
-                               l = BM_face_other_edge_loop(l1->f, l1->e, v);
+                               l = BM_loop_other_edge_loop(l1, 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_edge_loop(l2->f, l2->e, v);
+                                       l = BM_loop_other_edge_loop(l2, 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);
                                }
index c37d1cc2df46b16837797888eae95af0b931536a..ea3687ad7157e5ae878074534440f23a68abbb63 100644 (file)
@@ -154,7 +154,7 @@ void crazyspace_set_quats_editmesh(BMEditMesh *em, float *origcos, float *mapped
                        continue;
                
                BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
-                       BMLoop *l2 = BM_face_other_edge_loop(l->f, l->e, v);
+                       BMLoop *l2 = BM_loop_other_edge_loop(l, v);
                        
                        /* retrieve mapped coordinates */
                        v1 = mappedcos + 3 * BM_elem_index_get(l->v);