Fix T47564: Unwrapping the same mesh results in different UVs.

Pointers of faces were passed as face keys during parametrizer's face creation. Since those
addresses were different for every run, the layout of the faces ended up being different
in the internal hash, leading to inconsistent order of their evaluation during LSCM solving,
and slightly different UV maps.

Solved by simply using faces' indices as key instead, which ensures we always get same results
with exact same input data now.

Many thanks to Roman Nagornov (RomanN) for raising the issue, investigating it and finding
the solution! And thanks to Brecht for quick review too.
This commit is contained in:
Bastien Montagne 2016-03-02 12:21:53 +01:00
parent 36f35268b3
commit 0d12e086f5
Notes: blender-bot 2023-02-14 08:10:10 +01:00
Referenced by issue #47564, Unwrapping the same mesh results in different UVs and alter Export
1 changed files with 6 additions and 5 deletions

View File

@ -217,7 +217,7 @@ void ED_uvedit_get_aspect(Scene *scene, Object *ob, BMesh *bm, float *aspx, floa
}
static void construct_param_handle_face_add(ParamHandle *handle, Scene *scene,
BMFace *efa, const int cd_loop_uv_offset)
BMFace *efa, int face_index, const int cd_loop_uv_offset)
{
ParamKey key;
ParamKey *vkeys = BLI_array_alloca(vkeys, efa->len);
@ -230,7 +230,7 @@ static void construct_param_handle_face_add(ParamHandle *handle, Scene *scene,
BMIter liter;
BMLoop *l;
key = (ParamKey)efa;
key = (ParamKey)face_index;
/* let parametrizer split the ngon, it can make better decisions
* about which split is best for unwrapping than scanfill */
@ -256,6 +256,7 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm,
BMLoop *l;
BMEdge *eed;
BMIter iter, liter;
int i;
const int cd_loop_uv_offset = CustomData_get_offset(&bm->ldata, CD_MLOOPUV);
@ -273,7 +274,7 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm,
/* we need the vert indices */
BM_mesh_elem_index_ensure(bm, BM_VERT);
BM_ITER_MESH (efa, &iter, bm, BM_FACES_OF_MESH) {
BM_ITER_MESH_INDEX (efa, &iter, bm, BM_FACES_OF_MESH, i) {
if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0)) {
continue;
@ -293,7 +294,7 @@ static ParamHandle *construct_param_handle(Scene *scene, Object *ob, BMesh *bm,
}
}
construct_param_handle_face_add(handle, scene, efa, cd_loop_uv_offset);
construct_param_handle_face_add(handle, scene, efa, i, cd_loop_uv_offset);
}
if (!implicit) {
@ -449,7 +450,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, Object *ob, B
/* We will not check for v4 here. Subsurfed mfaces always have 4 vertices. */
BLI_assert(mpoly->totloop == 4);
key = (ParamKey)mpoly;
key = (ParamKey)i;
vkeys[0] = (ParamKey)mloop[0].v;
vkeys[1] = (ParamKey)mloop[1].v;
vkeys[2] = (ParamKey)mloop[2].v;