Revision: 25445
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25445
Author:   theeth
Date:     2009-12-17 18:34:56 +0100 (Thu, 17 Dec 2009)

Log Message:
-----------
Bugfix: [#20406] reapeat duplication along axis+view transform orientation

Saving back orientation in operator didn't take into account that constraint 
orientation can be different than user selected orientation.

Also simplify the switching logic a little.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/transform/transform.c
    trunk/blender/source/blender/editors/transform/transform.h
    trunk/blender/source/blender/editors/transform/transform_constraints.c

Modified: trunk/blender/source/blender/editors/transform/transform.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.c  2009-12-17 
17:15:38 UTC (rev 25444)
+++ trunk/blender/source/blender/editors/transform/transform.c  2009-12-17 
17:34:56 UTC (rev 25445)
@@ -673,7 +673,7 @@
                                        }
                                        else {
                                                if (t->flag & T_2D_EDIT) {
-                                                       setConstraint(t, mati, 
(CON_AXIS0), "along X axis");
+                                                       setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS0), "along X");
                                                }
                                                else {
                                                        setUserConstraint(t, 
t->current_orientation, (CON_AXIS0), "along %s X");
@@ -689,7 +689,7 @@
                                        }
                                        else {
                                                if (t->flag & T_2D_EDIT) {
-                                                       setConstraint(t, mati, 
(CON_AXIS1), "along Y axis");
+                                                       setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS1), "along Y");
                                                }
                                                else {
                                                        setUserConstraint(t, 
t->current_orientation, (CON_AXIS1), "along %s Y");
@@ -699,17 +699,12 @@
                                }
                                break;
                        case TFM_MODAL_AXIS_Z:
-                               if ((t->flag & T_NO_CONSTRAINT)==0) {
+                               if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))== 
0) {
                                        if (cmode == 'Z') {
                                                stopConstraint(t);
                                        }
                                        else {
-                                               if (t->flag & T_2D_EDIT) {
-                                                       setConstraint(t, mati, 
(CON_AXIS0), "along Z axis");
-                                               }
-                                               else {
-                                                       setUserConstraint(t, 
t->current_orientation, (CON_AXIS2), "along %s Z");
-                                               }
+                                               setUserConstraint(t, 
t->current_orientation, (CON_AXIS2), "along %s Z");
                                        }
                                        t->redraw = 1;
                                }
@@ -886,32 +881,28 @@
                        break;
                case XKEY:
                        if ((t->flag & T_NO_CONSTRAINT)==0) {
-                               if (cmode == 'X') {
-                                       if (t->flag & T_2D_EDIT) {
+                               if (t->flag & T_2D_EDIT) {
+                                       if (cmode == 'X') {
                                                stopConstraint(t);
+                                       } else {
+                                               setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS0), "along X");
                                        }
-                                       else {
-                                               if (t->con.mode & CON_USER) {
+                               } else {
+                                       if (cmode == 'X') {
+                                               if (t->con.orientation != 
V3D_MANIP_GLOBAL) {
                                                        stopConstraint(t);
-                                               }
-                                               else {
+                                               } else {
                                                        short orientation = 
t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : 
V3D_MANIP_LOCAL;
                                                        if ((t->modifiers & 
MOD_CONSTRAINT_PLANE) == 0)
                                                                
setUserConstraint(t, orientation, (CON_AXIS0), "along %s X");
                                                        else if (t->modifiers & 
MOD_CONSTRAINT_PLANE)
                                                                
setUserConstraint(t, orientation, (CON_AXIS1|CON_AXIS2), "locking %s X");
                                                }
-                                       }
-                               }
-                               else {
-                                       if (t->flag & T_2D_EDIT) {
-                                               setConstraint(t, mati, 
(CON_AXIS0), "along X axis");
-                                       }
-                                       else {
+                                       } else {
                                                if ((t->modifiers & 
MOD_CONSTRAINT_PLANE) == 0)
-                                                       setConstraint(t, mati, 
(CON_AXIS0), "along global X");
+                                                       setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS0), "along %s X");
                                                else if (t->modifiers & 
MOD_CONSTRAINT_PLANE)
-                                                       setConstraint(t, mati, 
(CON_AXIS1|CON_AXIS2), "locking global X");
+                                                       setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS1|CON_AXIS2), "locking %s X");
                                        }
                                }
                                t->redraw = 1;
@@ -919,56 +910,50 @@
                        break;
                case YKEY:
                        if ((t->flag & T_NO_CONSTRAINT)==0) {
-                               if (cmode == 'Y') {
-                                       if (t->flag & T_2D_EDIT) {
+                               if (t->flag & T_2D_EDIT) {
+                                       if (cmode == 'Y') {
                                                stopConstraint(t);
+                                       } else {
+                                               setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS1), "along Y");
                                        }
-                                       else {
-                                               if (t->con.mode & CON_USER) {
+                               } else {
+                                       if (cmode == 'Y') {
+                                               if (t->con.orientation != 
V3D_MANIP_GLOBAL) {
                                                        stopConstraint(t);
-                                               }
-                                               else {
+                                               } else {
                                                        short orientation = 
t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : 
V3D_MANIP_LOCAL;
                                                        if ((t->modifiers & 
MOD_CONSTRAINT_PLANE) == 0)
                                                                
setUserConstraint(t, orientation, (CON_AXIS1), "along %s Y");
                                                        else if (t->modifiers & 
MOD_CONSTRAINT_PLANE)
                                                                
setUserConstraint(t, orientation, (CON_AXIS0|CON_AXIS2), "locking %s Y");
                                                }
-                                       }
-                               }
-                               else {
-                                       if (t->flag & T_2D_EDIT) {
-                                               setConstraint(t, mati, 
(CON_AXIS1), "along Y axis");
-                                       }
-                                       else {
+                                       } else {
                                                if ((t->modifiers & 
MOD_CONSTRAINT_PLANE) == 0)
-                                                       setConstraint(t, mati, 
(CON_AXIS1), "along global Y");
+                                                       setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS1), "along %s Y");
                                                else if (t->modifiers & 
MOD_CONSTRAINT_PLANE)
-                                                       setConstraint(t, mati, 
(CON_AXIS0|CON_AXIS2), "locking global Y");
+                                                       setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS0|CON_AXIS2), "locking %s Y");
                                        }
                                }
                                t->redraw = 1;
                        }
                        break;
                case ZKEY:
-                       if ((t->flag & T_NO_CONSTRAINT)==0) {
+                       if ((t->flag & (T_NO_CONSTRAINT|T_2D_EDIT))==0) {
                                if (cmode == 'Z') {
-                                       if (t->con.mode & CON_USER) {
+                                       if (t->con.orientation != 
V3D_MANIP_GLOBAL) {
                                                stopConstraint(t);
-                                       }
-                                       else {
+                                       } else {
                                                short orientation = 
t->current_orientation != V3D_MANIP_GLOBAL ? t->current_orientation : 
V3D_MANIP_LOCAL;
                                                if ((t->modifiers & 
MOD_CONSTRAINT_PLANE) == 0)
                                                        setUserConstraint(t, 
orientation, (CON_AXIS2), "along %s Z");
-                                               else if ((t->modifiers & 
MOD_CONSTRAINT_PLANE) && ((t->flag & T_2D_EDIT)==0))
+                                               else if (t->modifiers & 
MOD_CONSTRAINT_PLANE)
                                                        setUserConstraint(t, 
orientation, (CON_AXIS0|CON_AXIS1), "locking %s Z");
                                        }
-                               }
-                               else if ((t->flag & T_2D_EDIT)==0) {
+                               } else {
                                        if ((t->modifiers & 
MOD_CONSTRAINT_PLANE) == 0)
-                                               setConstraint(t, mati, 
(CON_AXIS2), "along global Z");
+                                               setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS2), "along %s Z");
                                        else if (t->modifiers & 
MOD_CONSTRAINT_PLANE)
-                                               setConstraint(t, mati, 
(CON_AXIS0|CON_AXIS1), "locking global Z");
+                                               setUserConstraint(t, 
V3D_MANIP_GLOBAL, (CON_AXIS0|CON_AXIS1), "locking %s Z");
                                }
                                t->redraw = 1;
                        }
@@ -1464,7 +1449,14 @@
 
        if (RNA_struct_find_property(op->ptr, "constraint_axis"))
        {
-               RNA_enum_set(op->ptr, "constraint_orientation", 
t->current_orientation);
+               /* constraint orientation can be global, event if user selects 
something else
+                * so use the orientation in the constraint if set
+                * */
+               if (t->con.mode & CON_APPLY) {
+                       RNA_enum_set(op->ptr, "constraint_orientation", 
t->con.orientation);
+               } else {
+                       RNA_enum_set(op->ptr, "constraint_orientation", 
t->current_orientation);
+               }
 
                if (t->con.mode & CON_APPLY)
                {

Modified: trunk/blender/source/blender/editors/transform/transform.h
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.h  2009-12-17 
17:15:38 UTC (rev 25444)
+++ trunk/blender/source/blender/editors/transform/transform.h  2009-12-17 
17:34:56 UTC (rev 25445)
@@ -112,6 +112,7 @@
 } TransSnap;
 
 typedef struct TransCon {
+       short orientation;       /**/
     char  text[50];      /* Description of the Constraint for header_print     
                       */
     float mtx[3][3];     /* Matrix of the Constraint space                     
                       */
     float imtx[3][3];    /* Inverse Matrix of the Constraint space             
                       */

Modified: trunk/blender/source/blender/editors/transform/transform_constraints.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_constraints.c      
2009-12-17 17:15:38 UTC (rev 25444)
+++ trunk/blender/source/blender/editors/transform/transform_constraints.c      
2009-12-17 17:34:56 UTC (rev 25445)
@@ -599,6 +599,8 @@
                break;
        }
 
+       t->con.orientation = orientation;
+
        t->con.mode |= CON_USER;
 }
 


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

Reply via email to