BMesh: minor optimization for UV island walker

This commit is contained in:
Campbell Barton 2015-06-20 16:39:05 +10:00
parent 74b32a23f7
commit e807520a1e
1 changed files with 26 additions and 24 deletions

View File

@ -1441,17 +1441,16 @@ static void *bmw_UVEdgeWalker_yield(BMWalker *walker)
static void *bmw_UVEdgeWalker_step(BMWalker *walker)
{
const int type = walker->bm->ldata.layers[walker->layer].type;
const int offset = walker->bm->ldata.layers[walker->layer].offset;
BMwUVEdgeWalker *lwalk, owalk;
BMLoop *l, *l2, *l3, *nl, *cl;
BMIter liter;
void *d1, *d2;
int i, j, rlen;
BMLoop *l;
int i;
BMW_state_remove_r(walker, &owalk);
lwalk = &owalk;
l = lwalk->l;
nl = l->next;
if (!bmw_mask_check_edge(walker, l->e)) {
return l;
@ -1460,37 +1459,40 @@ static void *bmw_UVEdgeWalker_step(BMWalker *walker)
/* go over loops around l->v and nl->v and see which ones share l and nl's
* mloopuv's coordinates. in addition, push on l->next if necessary */
for (i = 0; i < 2; i++) {
cl = i ? nl : l;
BM_ITER_ELEM (l2, &liter, cl->v, BM_LOOPS_OF_VERT) {
d1 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
cl->head.data, walker->layer);
rlen = BM_edge_face_count(l2->e);
for (j = 0; j < rlen; j++) {
if (BLI_gset_haskey(walker->visit_set, l2)) {
BMIter liter;
BMLoop *l_pivot, *l_radial;
l_pivot = i ? l->next : l;
BM_ITER_ELEM (l_radial, &liter, l_pivot->v, BM_LOOPS_OF_VERT) {
BMLoop *l_radial_first = l_radial;
void *data_pivot = BM_ELEM_CD_GET_VOID_P(l_pivot, offset);
do {
BMLoop *l_other;
void *data_other;
if (BLI_gset_haskey(walker->visit_set, l_radial)) {
continue;
}
if (!bmw_mask_check_edge(walker, l2->e)) {
if (l2->v != cl->v) {
if (l_radial->v != l_pivot->v) {
if (!bmw_mask_check_edge(walker, l_radial->e)) {
continue;
}
}
l3 = l2->v != cl->v ? l2->next : l2;
d2 = CustomData_bmesh_get_layer_n(&walker->bm->ldata,
l3->head.data, walker->layer);
l_other = (l_radial->v != l_pivot->v) ? l_radial->next : l_radial;
data_other = BM_ELEM_CD_GET_VOID_P(l_other, offset);
if (!CustomData_data_equals(type, d1, d2))
if (!CustomData_data_equals(type, data_pivot, data_other))
continue;
lwalk = BMW_state_add(walker);
BLI_gset_insert(walker->visit_set, l2);
BLI_gset_insert(walker->visit_set, l_radial);
lwalk->l = l2;
lwalk->l = l_radial;
l2 = l2->radial_next;
}
} while ((l_radial = l_radial->radial_next) != l_radial_first);
}
}