Transform: UV islands were split by winding

This meant front/back faces from a projection would be seen as separate islands.
This commit is contained in:
2015-06-20 19:28:51 +10:00
parent e3fe56d9d1
commit e019d8fb8c
6 changed files with 55 additions and 30 deletions

View File

@@ -79,14 +79,12 @@ UvVertMap *BKE_mesh_uv_vert_map_create(
if (totuv == 0)
return NULL;
winding = MEM_callocN(sizeof(*winding) * totpoly, "winding");
vmap = (UvVertMap *)MEM_callocN(sizeof(*vmap), "UvVertMap");
if (!vmap)
return NULL;
vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*");
buf = vmap->buf = (UvMapVert *)MEM_callocN(sizeof(*vmap->buf) * (size_t)totuv, "UvMapVert");
vmap->vert = (UvMapVert **)MEM_callocN(sizeof(*vmap->vert) * totvert, "UvMapVert*");
if (use_winding) {
winding = MEM_callocN(sizeof(*winding) * totpoly, "winding");
}
if (!vmap->vert || !vmap->buf) {
BKE_mesh_uv_vert_map_free(vmap);
@@ -96,7 +94,11 @@ UvVertMap *BKE_mesh_uv_vert_map_create(
mp = mpoly;
for (a = 0; a < totpoly; a++, mp++) {
if (!selected || (!(mp->flag & ME_HIDE) && (mp->flag & ME_FACE_SEL))) {
float (*tf_uv)[2] = (float (*)[2])BLI_buffer_resize_data(&tf_uv_buf, vec2f, mp->totloop);
float (*tf_uv)[2];
if (use_winding) {
tf_uv = (float (*)[2])BLI_buffer_resize_data(&tf_uv_buf, vec2f, mp->totloop);
}
nverts = mp->totloop;
@@ -107,14 +109,16 @@ UvVertMap *BKE_mesh_uv_vert_map_create(
buf->next = vmap->vert[mloop[mp->loopstart + i].v];
vmap->vert[mloop[mp->loopstart + i].v] = buf;
copy_v2_v2(tf_uv[i], mloopuv[mpoly[a].loopstart + i].uv);
if (use_winding) {
copy_v2_v2(tf_uv[i], mloopuv[mpoly[a].loopstart + i].uv);
}
buf++;
}
if (use_winding)
if (use_winding) {
winding[a] = cross_poly_v2((const float (*)[2])tf_uv, (unsigned int)nverts) > 0;
else
winding[a] = 0;
}
}
}
@@ -142,7 +146,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(
if (fabsf(uv[0] - uv2[0]) < limit[0] && fabsf(uv[1] - uv2[1]) < limit[1] &&
winding[iterv->f] == winding[v->f])
(!use_winding || winding[iterv->f] == winding[v->f]))
{
if (lastv) lastv->next = next;
else vlist = next;
@@ -161,7 +165,10 @@ UvVertMap *BKE_mesh_uv_vert_map_create(
vmap->vert[a] = newvlist;
}
MEM_freeN(winding);
if (use_winding) {
MEM_freeN(winding);
}
BLI_buffer_free(&tf_uv_buf);
return vmap;