simple optimization, replace BM_face_other_edge_loop() with BM_loop_other_edge_loop() in situations where the loop is known this avoids a lookup.
This commit is contained in:
parent
f2f27bf832
commit
34f9932418
@ -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;
|
||||
BMLoop *l = BM_face_edge_share_loop(f, e);
|
||||
BLI_assert(l != NULL);
|
||||
return BM_loop_other_edge_loop(l, v);
|
||||
}
|
||||
|
||||
/* 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 && 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user