From 15d77f17a40398a63f95e16607deb81257c02698 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 10 Sep 2009 11:04:53 +0000 Subject: 2.5: UV Edit * Make mirror operator and menus work. * Added TFM_OT_mirror transform operator specific for mirror. * Assign image from image space when unwrapping in 3d view. --- source/blender/editors/uvedit/uvedit_ops.c | 45 ----------------------- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 33 +++++++++++++++-- 2 files changed, 30 insertions(+), 48 deletions(-) (limited to 'source/blender/editors/uvedit') diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index a44421e8145..9051300e117 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -942,50 +942,6 @@ static void select_linked(Scene *scene, Image *ima, EditMesh *em, float limit[2] EM_free_uv_vert_map(vmap); } -/* ******************** mirror operator **************** */ - -static int mirror_exec(bContext *C, wmOperator *op) -{ - float mat[3][3]; - int axis; - - Mat3One(mat); - axis= RNA_enum_get(op->ptr, "axis"); - - if(axis == 'x') { - /* XXX initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setSingleAxisConstraint(mat[0], " on X axis"); - Transform(); */ - } - else { - /* XXX initTransform(TFM_MIRROR, CTX_NO_PET|CTX_AUTOCONFIRM); - BIF_setSingleAxisConstraint(mat[1], " on Y axis"); - Transform(); */ - } - - return OPERATOR_FINISHED; -} - -void UV_OT_mirror(wmOperatorType *ot) -{ - static EnumPropertyItem axis_items[] = { - {'x', "MIRROR_X", 0, "Mirror X", "Mirror UVs over X axis."}, - {'y', "MIRROR_Y", 0, "Mirror Y", "Mirror UVs over Y axis."}, - {0, NULL, 0, NULL, NULL}}; - - /* identifiers */ - ot->name= "Mirror"; - ot->idname= "UV_OT_mirror"; - ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO; - - /* api callbacks */ - ot->exec= mirror_exec; - ot->poll= ED_operator_uvedit; - - /* properties */ - RNA_def_enum(ot->srna, "axis", axis_items, 'x', "Axis", "Axis to mirror UV locations over."); -} - /* ******************** align operator **************** */ static void weld_align_uv(bContext *C, int tool) @@ -3092,7 +3048,6 @@ void ED_operatortypes_uvedit(void) WM_operatortype_append(UV_OT_snap_selection); WM_operatortype_append(UV_OT_align); - WM_operatortype_append(UV_OT_mirror); WM_operatortype_append(UV_OT_stitch); WM_operatortype_append(UV_OT_weld); WM_operatortype_append(UV_OT_pin); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index c18c9f8e022..b20d390fb4d 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -44,6 +44,7 @@ #include "BKE_customdata.h" #include "BKE_depsgraph.h" #include "BKE_global.h" +#include "BKE_image.h" #include "BKE_mesh.h" #include "BKE_utildefines.h" @@ -75,6 +76,11 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit) EditMesh *em= BKE_mesh_get_editmesh((Mesh*)obedit->data); EditFace *efa; MTFace *tf; + Image *ima; + bScreen *sc; + ScrArea *sa; + SpaceLink *slink; + SpaceImage *sima; if(ED_uvedit_test(obedit)) { BKE_mesh_end_editmesh(obedit->data, em); @@ -88,10 +94,31 @@ static int ED_uvedit_ensure_uvs(bContext *C, Scene *scene, Object *obedit) BKE_mesh_end_editmesh(obedit->data, em); return 0; } + + ima= CTX_data_edit_image(C); + + if(!ima) { + /* no image in context in the 3d view, we find first image window .. */ + sc= CTX_wm_screen(C); + + for(sa=sc->areabase.first; sa; sa=sa->next) { + slink= sa->spacedata.first; + if(slink->spacetype == SPACE_IMAGE) { + sima= (SpaceImage*)slink; + + ima= sima->image; + if(ima) { + if(ima->type==IMA_TYPE_R_RESULT || ima->type==IMA_TYPE_COMPOSITE) + ima= NULL; + else + break; + } + } + } + } - // XXX this image is not in context in 3d view .. only - // way to get would be to find the first image window? - ED_uvedit_assign_image(scene, obedit, CTX_data_edit_image(C), NULL); + if(ima) + ED_uvedit_assign_image(scene, obedit, ima, NULL); /* select new UV's */ for(efa=em->faces.first; efa; efa=efa->next) { -- cgit v1.2.3