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:
authorAntony Riakiotakis <kalast@gmail.com>2012-07-09 20:12:57 +0400
committerAntony Riakiotakis <kalast@gmail.com>2012-07-09 20:12:57 +0400
commit4c7f7b6dbf810a2f38a162ab9ca4f0af56a0c255 (patch)
tree73b1d6d301c8494b1814869f0f3f4f31e5d49794 /source/blender/editors/uvedit/uvedit_parametrizer.c
parent54ed3dee68c1a5b6db107e2a7454ff20e23123bb (diff)
Fix for #31962, changes image ignores correct aspect ratio. Made
unwrapper flush the correct aspect flag to mtpoly after unwrap. Faces that have been unwrapped with correct aspect option will fix their aspect each time a different image is assigned to them. I hope fix works 100%, I can't say that I really understood the bizarre aspect ratio system.
Diffstat (limited to 'source/blender/editors/uvedit/uvedit_parametrizer.c')
-rw-r--r--source/blender/editors/uvedit/uvedit_parametrizer.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c
index 87ff36ebf27..a2e276c09e3 100644
--- a/source/blender/editors/uvedit/uvedit_parametrizer.c
+++ b/source/blender/editors/uvedit/uvedit_parametrizer.c
@@ -145,6 +145,7 @@ typedef struct PFace {
struct PEdge *edge;
unsigned char flag;
+ short *unwrap_flag;
} PFace;
@@ -232,8 +233,11 @@ typedef struct PHandle {
RNG *rng;
float blend;
+ char do_aspect;
} PHandle;
+/* duplicate, to avoid including DNA_mesh_types.h */
+#define TF_CORRECT_ASPECT 256
/* PHash
* - special purpose hash that keeps all its elements in a single linked list.
@@ -646,6 +650,7 @@ static void p_vert_load_pin_select_uvs(PHandle *handle, PVert *v)
static void p_flush_uvs(PHandle *handle, PChart *chart)
{
PEdge *e;
+ PFace *f;
for (e = chart->edges; e; e = e->nextlink) {
if (e->orig_uv) {
@@ -653,6 +658,16 @@ static void p_flush_uvs(PHandle *handle, PChart *chart)
e->orig_uv[1] = e->vert->uv[1] / handle->aspy;
}
}
+
+ for (f = chart->faces; f; f = f->nextlink) {
+ if(f->unwrap_flag) {
+ if (handle->do_aspect) {
+ *f->unwrap_flag |= TF_CORRECT_ASPECT;
+ } else {
+ *f->unwrap_flag &= ~TF_CORRECT_ASPECT;
+ }
+ }
+ }
}
static void p_flush_uvs_blend(PHandle *handle, PChart *chart, float blend)
@@ -1042,6 +1057,7 @@ static PFace *p_face_add(PHandle *handle)
/* allocate */
f = (PFace *)BLI_memarena_alloc(handle->arena, sizeof *f);
f->flag = 0; // init !
+ f->unwrap_flag = NULL;
e1 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e1);
e2 = (PEdge *)BLI_memarena_alloc(handle->arena, sizeof *e2);
@@ -1068,7 +1084,7 @@ static PFace *p_face_add(PHandle *handle)
static PFace *p_face_add_construct(PHandle *handle, ParamKey key, ParamKey *vkeys,
float *co[3], float *uv[3], int i1, int i2, int i3,
- ParamBool *pin, ParamBool *select)
+ ParamBool *pin, ParamBool *select, short *unwrap_flag)
{
PFace *f = p_face_add(handle);
PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next;
@@ -1095,6 +1111,7 @@ static PFace *p_face_add_construct(PHandle *handle, ParamKey key, ParamKey *vkey
/* insert into hash */
f->u.key = key;
+ f->unwrap_flag = unwrap_flag;
phash_insert(handle->hash_faces, (PHashLink *)f);
e1->u.key = PHASH_edge(vkeys[i1], vkeys[i2]);
@@ -4087,6 +4104,7 @@ ParamHandle *param_construct_begin(void)
handle->arena = BLI_memarena_new((1 << 16), "param construct arena");
handle->aspx = 1.0f;
handle->aspy = 1.0f;
+ handle->do_aspect = FALSE;
handle->hash_verts = phash_new((PHashLink **)&handle->construction_chart->verts, 1);
handle->hash_edges = phash_new((PHashLink **)&handle->construction_chart->edges, 1);
@@ -4101,6 +4119,7 @@ void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy)
phandle->aspx = aspx;
phandle->aspy = aspy;
+ phandle->do_aspect = TRUE;
}
void param_delete(ParamHandle *handle)
@@ -4131,7 +4150,7 @@ void param_delete(ParamHandle *handle)
void param_face_add(ParamHandle *handle, ParamKey key, int nverts,
ParamKey *vkeys, float **co, float **uv,
- ParamBool *pin, ParamBool *select)
+ ParamBool *pin, ParamBool *select, short *unwrap_flag)
{
PHandle *phandle = (PHandle *)handle;
@@ -4141,16 +4160,16 @@ void param_face_add(ParamHandle *handle, ParamKey key, int nverts,
if (nverts == 4) {
if (p_quad_split_direction(phandle, co, vkeys)) {
- p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select);
- p_face_add_construct(phandle, key, vkeys, co, uv, 0, 2, 3, pin, select);
+ p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select, unwrap_flag);
+ p_face_add_construct(phandle, key, vkeys, co, uv, 0, 2, 3, pin, select, unwrap_flag);
}
else {
- p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 3, pin, select);
- p_face_add_construct(phandle, key, vkeys, co, uv, 1, 2, 3, pin, select);
+ p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 3, pin, select, unwrap_flag);
+ p_face_add_construct(phandle, key, vkeys, co, uv, 1, 2, 3, pin, select, unwrap_flag);
}
}
else if (!p_face_exists(phandle, vkeys, 0, 1, 2)) {
- p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select);
+ p_face_add_construct(phandle, key, vkeys, co, uv, 0, 1, 2, pin, select, unwrap_flag);
}
}