Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-04-15 14:31:07 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-04-15 14:31:07 +0400
commitcda6230a852c51dfe713b221132cbf30be6a1d5d (patch)
treef6ebf67d5aec3a7db82744c0d9696472b47242d5
parentdb53faffa3e86fb44bfa2a025a5261eb69d3bc09 (diff)
Fix #30952: uv unwrapper not working as well as 2.62 on some topologies, let the
unwrapper itself decide how to split quads since it has specific checks for the best unwrapping split built in, gives better results.
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c4
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.h2
-rw-r--r--source/blender/editors/uvedit/uvedit_unwrap_ops.c111
3 files changed, 59 insertions, 58 deletions
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index d2c711fccf3..c99d6e992b7 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -742,7 +742,7 @@ static PEdge *p_edge_lookup(PHandle *handle, PHashKey *vkeys)
return NULL;
}
-int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2, int i3)
+static int p_face_exists(ParamHandle *phandle, ParamKey *pvkeys, int i1, int i2, int i3)
{
PHandle *handle = (PHandle *)phandle;
PHashKey *vkeys = (PHashKey *)pvkeys;
@@ -4131,7 +4131,7 @@ void param_face_add(ParamHandle *handle, ParamKey key, int nverts,
p_face_add_construct(phandle, key, vkeys, co, uv, 1, 2, 3, pin, select);
}
}
- else
+ else if(!p_face_exists(phandle, vkeys, 0, 1, 2))
p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select);
}
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h
index 00cbbd16073..1643a89b089 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.h
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.h
@@ -33,8 +33,6 @@ ParamHandle *param_construct_begin(void);
void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy);
-int p_face_exists(ParamHandle *handle, ParamKey *vkeys, int i1, int i2, int i3);
-
void param_face_add(ParamHandle *handle,
ParamKey key,
int nverts,
diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
index f7e1ee221c0..54182350f1e 100644
--- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c
+++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c
@@ -220,10 +220,9 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
ParamKey key, vkeys[4];
ParamBool pin[4], select[4];
BMLoop *ls[3];
- MLoopUV *luvs[3];
float *co[4];
float *uv[4];
- int lsel;
+ int i, lsel;
if ((BM_elem_flag_test(efa, BM_ELEM_HIDDEN)) || (sel && BM_elem_flag_test(efa, BM_ELEM_SELECT) == 0))
continue;
@@ -242,69 +241,73 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em,
key = (ParamKey)efa;
- /* scanfill time! */
- BLI_begin_edgefill();
-
- firstv = lastv = NULL;
- BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
- int i;
-
- v = BLI_addfillvert(l->v->co);
-
- /* add small random offset */
- for (i = 0; i < 3; i++) {
- v->co[i] += (BLI_frand() - 0.5f) * FLT_EPSILON * 50;
- }
-
- v->tmp.p = l;
- if (lastv) {
- BLI_addfilledge(lastv, v);
+ if(efa->len == 3 || efa->len == 4) {
+ /* for quads let parametrize split, it can make better decisions
+ about which split is best for unwrapping than scanfill */
+ i = 0;
+ BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
+ MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, l->head.data, CD_MLOOPUV);
+ vkeys[i] = (ParamKey)BM_elem_index_get(l->v);
+ co[i] = l->v->co;
+ uv[i] = luv->uv;
+ pin[i] = (luv->flag & MLOOPUV_PINNED) != 0;
+ select[i] = uvedit_uv_selected(em, scene, l) != 0;
+
+ i++;
}
- lastv = v;
- if (!firstv)
- firstv = v;
+ param_face_add(handle, key, i, vkeys, co, uv, pin, select);
}
-
- BLI_addfilledge(firstv, v);
-
- /* mode 2 enables faster handling of tri/quads */
- BLI_edgefill(2);
- for (sefa = fillfacebase.first; sefa; sefa = sefa->next) {
- ls[0] = sefa->v1->tmp.p;
- ls[1] = sefa->v2->tmp.p;
- ls[2] = sefa->v3->tmp.p;
+ else {
+ /* ngon - scanfill time! */
+ BLI_begin_edgefill();
- luvs[0] = CustomData_bmesh_get(&em->bm->ldata, ls[0]->head.data, CD_MLOOPUV);
- luvs[1] = CustomData_bmesh_get(&em->bm->ldata, ls[1]->head.data, CD_MLOOPUV);
- luvs[2] = CustomData_bmesh_get(&em->bm->ldata, ls[2]->head.data, CD_MLOOPUV);
-
- vkeys[0] = (ParamKey)BM_elem_index_get(ls[0]->v);
- vkeys[1] = (ParamKey)BM_elem_index_get(ls[1]->v);
- vkeys[2] = (ParamKey)BM_elem_index_get(ls[2]->v);
-
- co[0] = ls[0]->v->co;
- co[1] = ls[1]->v->co;
- co[2] = ls[2]->v->co;
+ firstv = lastv = NULL;
+ BM_ITER(l, &liter, em->bm, BM_LOOPS_OF_FACE, efa) {
+ int i;
+
+ v = BLI_addfillvert(l->v->co);
+
+ /* add small random offset */
+ for (i = 0; i < 3; i++) {
+ v->co[i] += (BLI_frand() - 0.5f) * FLT_EPSILON * 50;
+ }
+
+ v->tmp.p = l;
- uv[0] = luvs[0]->uv;
- uv[1] = luvs[1]->uv;
- uv[2] = luvs[2]->uv;
+ if (lastv) {
+ BLI_addfilledge(lastv, v);
+ }
- pin[0] = (luvs[0]->flag & MLOOPUV_PINNED) != 0;
- pin[1] = (luvs[1]->flag & MLOOPUV_PINNED) != 0;
- pin[2] = (luvs[2]->flag & MLOOPUV_PINNED) != 0;
+ lastv = v;
+ if (!firstv)
+ firstv = v;
+ }
- select[0] = uvedit_uv_selected(em, scene, ls[0]) != 0;
- select[1] = uvedit_uv_selected(em, scene, ls[1]) != 0;
- select[2] = uvedit_uv_selected(em, scene, ls[2]) != 0;
+ BLI_addfilledge(firstv, v);
+
+ /* mode 2 enables faster handling of tri/quads */
+ BLI_edgefill(2);
+ for (sefa = fillfacebase.first; sefa; sefa = sefa->next) {
+ ls[0] = sefa->v1->tmp.p;
+ ls[1] = sefa->v2->tmp.p;
+ ls[2] = sefa->v3->tmp.p;
+
+ for(i = 0; i < 3; i++) {
+ MLoopUV *luv = CustomData_bmesh_get(&em->bm->ldata, ls[i]->head.data, CD_MLOOPUV);
+ vkeys[i] = (ParamKey)BM_elem_index_get(ls[i]->v);
+ co[i] = ls[i]->v->co;
+ uv[i] = luv->uv;
+ pin[i] = (luv->flag & MLOOPUV_PINNED) != 0;
+ select[i] = uvedit_uv_selected(em, scene, ls[i]) != 0;
+ }
- if (!p_face_exists(handle, vkeys, 0, 1, 2))
param_face_add(handle, key, 3, vkeys, co, uv, pin, select);
- }
+ }
- BLI_end_edgefill();
+ BLI_end_edgefill();
+ }
}
if (!implicit) {