diff options
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.c | 27 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_queries.h | 1 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_walkers_impl.c | 4 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_loopcut.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/editmesh_rip.c | 8 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 18 | ||||
-rw-r--r-- | source/blender/editors/util/crazyspace.c | 2 |
7 files changed, 32 insertions, 30 deletions
diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index c0db2c0a19e..f61c63ee6c5 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -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; } /** diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index ec52a7af162..3d3e1a3d9d9 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -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); diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index a50b708961c..55d9153fd63 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -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; diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 1bd6f285706..626f372c661 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -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; diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index b4c31b2df91..c9e248e575d 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -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)); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ca73405fb16..2bc587d8f73 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -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); } diff --git a/source/blender/editors/util/crazyspace.c b/source/blender/editors/util/crazyspace.c index c37d1cc2df4..ea3687ad715 100644 --- a/source/blender/editors/util/crazyspace.c +++ b/source/blender/editors/util/crazyspace.c @@ -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); |