diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-06 23:28:22 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-06 23:28:22 +0400 |
commit | d5b9ae57ca1b76ae1a2c296e83cc91029d373cea (patch) | |
tree | 83f4a78562886cd88abdcb63d7049d444eae2151 /source | |
parent | 43c3fa6c39214b018801caf80873c62755770aec (diff) |
Switching images in the image space would modify UV coordinates.
This is an intended feature but works too unreliably.
- This setting was stored in each face and only editable by re-running the unwrap, this is too hidden (only discovered this by reading code).
- This worked with blender internal but not with cycles, such basic options as changing an image shouldn't behave different depending on the render engine selected.
I've ifdef'd out the aspect correction for now, it could be added back as a per scene option and be made to run on both cycles or blender internal but for now I prefer to keep this disabled.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/uvedit/uvedit_ops.c | 11 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_parametrizer.c | 33 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_parametrizer.h | 16 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_unwrap_ops.c | 10 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_meshdata_types.h | 6 |
5 files changed, 30 insertions, 46 deletions
diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 4154e363292..de1d51b2204 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -165,6 +165,8 @@ void ED_object_assign_active_image(Main *bmain, Object *ob, int mat_nr, Image *i /************************* assign image ************************/ +//#define USE_SWITCH_ASPECT + void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *ima, Image *previma) { BMEditMesh *em; @@ -196,6 +198,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im } else { /* old shading system, assign image to selected faces */ +#ifdef USE_SWITCH_ASPECT float prev_aspect[2], fprev_aspect; float aspect[2], faspect; @@ -204,6 +207,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im fprev_aspect = prev_aspect[0]/prev_aspect[1]; faspect = aspect[0]/aspect[1]; +#endif /* ensure we have a uv map */ if (!CustomData_has_layer(&em->bm->pdata, CD_MTEXPOLY)) { @@ -223,8 +227,12 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im if (ima->id.us == 0) id_us_plus(&ima->id); else id_lib_extern(&ima->id); +#ifdef USE_SWITCH_ASPECT /* we also need to correct the aspect of uvs */ - if (tf->unwrap & TF_CORRECT_ASPECT) { + if (scene->toolsettings->uvcalc_flag & UVCALC_NO_ASPECT_CORRECT) { + /* do nothing */ + } + else { BMIter liter; BMLoop *l; @@ -235,6 +243,7 @@ void ED_uvedit_assign_image(Main *bmain, Scene *scene, Object *obedit, Image *im luv->uv[0] /= faspect; } } +#endif } else { tf->tpage = NULL; diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 39a78ea934b..2161d4989db 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -145,8 +145,6 @@ typedef struct PFace { struct PEdge *edge; unsigned char flag; - short *unwrap_flag; - } PFace; enum PVertFlag { @@ -236,9 +234,6 @@ typedef struct PHandle { 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. * - after construction, this hash is thrown away, and the list remains. @@ -650,7 +645,6 @@ 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) { @@ -658,17 +652,6 @@ 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) @@ -1058,7 +1041,6 @@ 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); @@ -1085,7 +1067,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, short *unwrap_flag) + ParamBool *pin, ParamBool *select) { PFace *f = p_face_add(handle); PEdge *e1 = f->edge, *e2 = e1->next, *e3 = e2->next; @@ -1112,7 +1094,6 @@ 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]); @@ -4151,7 +4132,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, short *unwrap_flag) + ParamBool *pin, ParamBool *select) { PHandle *phandle = (PHandle *)handle; @@ -4161,16 +4142,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, unwrap_flag); - p_face_add_construct(phandle, key, vkeys, co, uv, 0, 2, 3, pin, select, unwrap_flag); + 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); } else { - 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); + 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); } } else if (!p_face_exists(phandle, vkeys, 0, 1, 2)) { - 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, 1, 2, pin, select); } } diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.h b/source/blender/editors/uvedit/uvedit_parametrizer.h index 9a2fea0d7f9..4c23d49428b 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.h +++ b/source/blender/editors/uvedit/uvedit_parametrizer.h @@ -56,16 +56,16 @@ ParamHandle *param_construct_begin(void); void param_aspect_ratio(ParamHandle *handle, float aspx, float aspy); void param_face_add(ParamHandle *handle, - ParamKey key, - int nverts, - ParamKey *vkeys, - float **co, - float **uv, - ParamBool *pin, - ParamBool *select, short *unwrap_flag); + ParamKey key, + int nverts, + ParamKey *vkeys, + float **co, + float **uv, + ParamBool *pin, + ParamBool *select); void param_edge_set_seam(ParamHandle *handle, - ParamKey *vkeys); + ParamKey *vkeys); void param_construct_end(ParamHandle *handle, ParamBool fill, ParamBool impl); void param_delete(ParamHandle *chart); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 4b6c0ef0e7b..682b35072f6 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -213,7 +213,6 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, BLI_srand(0); BM_ITER_MESH (efa, &iter, em->bm, BM_FACES_OF_MESH) { - MTexPoly *tf; ScanFillVert *sf_vert, *sf_vert_last, *sf_vert_first; ScanFillFace *sf_tri; ParamKey key, vkeys[4]; @@ -257,7 +256,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, i++; } - param_face_add(handle, key, i, vkeys, co, uv, pin, select, &tf->unwrap); + param_face_add(handle, key, i, vkeys, co, uv, pin, select); } else { /* ngon - scanfill time! */ @@ -302,7 +301,7 @@ static ParamHandle *construct_param_handle(Scene *scene, BMEditMesh *em, select[i] = uvedit_uv_select_test(em, scene, ls[i]) != 0; } - param_face_add(handle, key, 3, vkeys, co, uv, pin, select, &tf->unwrap); + param_face_add(handle, key, 3, vkeys, co, uv, pin, select); } BLI_scanfill_end(&sf_ctx); @@ -446,7 +445,6 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e float *co[4]; float *uv[4]; BMFace *origFace = faceMap[i]; - MTexPoly *tf; face = subsurfedFaces + i; @@ -459,8 +457,6 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e continue; } - tf = CustomData_bmesh_get(&em->bm->pdata, origFace->head.data, CD_MTEXPOLY); - /* We will not check for v4 here. Subsurfed mfaces always have 4 vertices. */ key = (ParamKey)face; vkeys[0] = (ParamKey)face->v1; @@ -480,7 +476,7 @@ static ParamHandle *construct_param_handle_subsurfed(Scene *scene, BMEditMesh *e texface_from_original_index(origFace, origVertIndices[face->v3], &uv[2], &pin[2], &select[2], scene, em); texface_from_original_index(origFace, origVertIndices[face->v4], &uv[3], &pin[3], &select[3], scene, em); - param_face_add(handle, key, 4, vkeys, co, uv, pin, select, &tf->unwrap); + param_face_add(handle, key, 4, vkeys, co, uv, pin, select); } /* these are calculated from original mesh too */ diff --git a/source/blender/makesdna/DNA_meshdata_types.h b/source/blender/makesdna/DNA_meshdata_types.h index 9ae2bec583d..2f5ef9c2aaa 100644 --- a/source/blender/makesdna/DNA_meshdata_types.h +++ b/source/blender/makesdna/DNA_meshdata_types.h @@ -95,7 +95,7 @@ typedef struct MLoop { typedef struct MTexPoly { struct Image *tpage; char flag, transp; - short mode, tile, unwrap; + short mode, tile, pad; } MTexPoly; /* can copy from/to MTexPoly/MTFace */ @@ -106,8 +106,7 @@ typedef struct MTexPoly { (dst)->transp = (src)->transp; \ (dst)->mode = (src)->mode; \ (dst)->tile = (src)->tile; \ - (dst)->unwrap = (src)->unwrap; \ -} +} (void)0 typedef struct MLoopUV { float uv[2]; @@ -368,6 +367,5 @@ typedef struct MVertSkin { #define TF_PIN2 32 #define TF_PIN3 64 #define TF_PIN4 128 -#define TF_CORRECT_ASPECT 256 #endif |