Bugfix: [#20406] reapeat duplication along axis+view transform orientation
authorMartin Poirier <theeth@yahoo.com>
Thu, 17 Dec 2009 17:34:56 +0000 (17:34 +0000)
committerMartin Poirier <theeth@yahoo.com>
Thu, 17 Dec 2009 17:34:56 +0000 (17:34 +0000)
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.

source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_constraints.c

index 312939961f577860a3527673b206d7c1c7ce6b1d..36e8032b64014bd8c1e3786799defdab01e248b9 100644 (file)
@@ -673,7 +673,7 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                        }
                                        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 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                        }
                                        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 @@ int transformEvent(TransInfo *t, wmEvent *event)
                                }
                                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 @@ int transformEvent(TransInfo *t, wmEvent *event)
                        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 @@ int transformEvent(TransInfo *t, wmEvent *event)
                        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 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
 
        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)
                {
index 0b8fb365a56944b9864729d05c402d88eefbf9a0..3b1ead32fadf1e9cf56c6ea99ca2be0c0359dbb7 100644 (file)
@@ -112,6 +112,7 @@ typedef struct TransSnap {
 } 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                                    */
index 1f42d9411f17f3342e4f191a82e4d05434a6d2e8..fd53f6fcd2007f8af6841ee8ca6e71cb62539387 100644 (file)
@@ -599,6 +599,8 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
                break;
        }
 
+       t->con.orientation = orientation;
+
        t->con.mode |= CON_USER;
 }