diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2016-03-02 14:21:53 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2016-03-02 14:21:53 +0300 |
commit | 0d12e086f5dda74d43e3a2d011bfc848c95136de (patch) | |
tree | ca0a56662a5308ec6f937b8a421f5b2bcaa20b93 /source | |
parent | 36f35268b3cd36f346264d599ef1b97bee66ee58 (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 3f218136751..9f2b0f1af14 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -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; |