Revision: 23107
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23107
Author:   blendix
Date:     2009-09-10 13:04:53 +0200 (Thu, 10 Sep 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/transform/transform.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_ops.c
    branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_ops.c
    
branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c

Modified: 
branches/blender2.5/blender/source/blender/editors/transform/transform.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.c    
2009-09-10 10:35:51 UTC (rev 23106)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.c    
2009-09-10 11:04:53 UTC (rev 23107)
@@ -1257,14 +1257,17 @@
        int constraint_axis[3] = {0, 0, 0};
        int proportional = 0;
 
-       if (t->flag & T_AUTOVALUES)
+       if (RNA_struct_find_property(op->ptr, "value"))
        {
-               RNA_float_set_array(op->ptr, "value", t->auto_values);
+               if (t->flag & T_AUTOVALUES)
+               {
+                       RNA_float_set_array(op->ptr, "value", t->auto_values);
+               }
+               else
+               {
+                       RNA_float_set_array(op->ptr, "value", t->values);
+               }
        }
-       else
-       {
-               RNA_float_set_array(op->ptr, "value", t->values);
-       }
 
        /* XXX convert stupid flag to enum */
        switch(t->flag & (T_PROP_EDIT|T_PROP_CONNECTED))
@@ -4145,7 +4148,10 @@
 
                recalcData(t);
 
-               ED_area_headerprint(t->sa, "Select a mirror axis (X, Y, Z)");
+               if(t->flag & T_2D_EDIT)
+                       ED_area_headerprint(t->sa, "Select a mirror axis (X, 
Y)");
+               else
+                       ED_area_headerprint(t->sa, "Select a mirror axis (X, Y, 
Z)");
        }
 
        return 1;

Modified: 
branches/blender2.5/blender/source/blender/editors/transform/transform_ops.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/transform/transform_ops.c    
    2009-09-10 10:35:51 UTC (rev 23106)
+++ 
branches/blender2.5/blender/source/blender/editors/transform/transform_ops.c    
    2009-09-10 11:04:53 UTC (rev 23107)
@@ -98,6 +98,7 @@
 char OP_SHRINK_FATTEN[] = "TFM_OT_shrink_fatten";
 char OP_TILT[] = "TFM_OT_tilt";
 char OP_TRACKBALL[] = "TFM_OT_trackball";
+char OP_MIRROR[] = "TFM_OT_mirror";
 
 
 TransformModeItem transform_modes[] =
@@ -111,6 +112,7 @@
        {OP_SHRINK_FATTEN, TFM_SHRINKFATTEN},
        {OP_TILT, TFM_TILT},
        {OP_TRACKBALL, TFM_TRACKBALL},
+       {OP_MIRROR, TFM_MIRROR},
        {NULL, 0}
 };
 
@@ -528,6 +530,25 @@
        RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
 }
 
+void TFM_OT_mirror(struct wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name   = "Mirror";
+       ot->description= "Mirror selected vertices around one or more axes.";
+       ot->idname = OP_MIRROR;
+       ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO|OPTYPE_BLOCKING;
+
+       /* api callbacks */
+       ot->invoke = transform_invoke;
+       ot->exec   = transform_exec;
+       ot->modal  = transform_modal;
+       ot->cancel  = transform_cancel;
+       ot->poll   = ED_operator_areaactive;
+
+       Properties_Proportional(ot);
+       Properties_Constraints(ot);
+}
+
 void TFM_OT_transform(struct wmOperatorType *ot)
 {
        static EnumPropertyItem transform_mode_types[] = {
@@ -595,6 +616,7 @@
        WM_operatortype_append(TFM_OT_shrink_fatten);
        WM_operatortype_append(TFM_OT_tilt);
        WM_operatortype_append(TFM_OT_trackball);
+       WM_operatortype_append(TFM_OT_mirror);
 
        WM_operatortype_append(TFM_OT_select_orientation);
 }
@@ -699,8 +721,7 @@
 
                        km = WM_keymap_add_item(keymap, "TFM_OT_resize", SKEY, 
KM_PRESS, 0, 0);
 
-                       km = WM_keymap_add_item(keymap, "TFM_OT_transform", 
MKEY, KM_PRESS, 0, 0);
-                       RNA_int_set(km->ptr, "mode", TFM_MIRROR);
+                       km = WM_keymap_add_item(keymap, "TFM_OT_mirror", MKEY, 
KM_PRESS, 0, 0);
                        break;
                default:
                        break;

Modified: branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_ops.c      
2009-09-10 10:35:51 UTC (rev 23106)
+++ branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_ops.c      
2009-09-10 11:04:53 UTC (rev 23107)
@@ -942,50 +942,6 @@
        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 @@
        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);

Modified: 
branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c   
    2009-09-10 10:35:51 UTC (rev 23106)
+++ 
branches/blender2.5/blender/source/blender/editors/uvedit/uvedit_unwrap_ops.c   
    2009-09-10 11:04:53 UTC (rev 23107)
@@ -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 @@
        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 @@
                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) {

Modified: 
branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c     
2009-09-10 10:35:51 UTC (rev 23106)
+++ branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c     
2009-09-10 11:04:53 UTC (rev 23107)
@@ -2748,7 +2748,7 @@
                return (rna_idproperty_find(ptr, name) != NULL);
        }
        else {
-               printf("RNA_property_is_set: %s.%s not found.\n", 
ptr->type->identifier, name);
+               // printf("RNA_property_is_set: %s.%s not found.\n", 
ptr->type->identifier, name);
                return 0;
        }
 }


_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to