Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / transform / transform.c
index 1f2589d8a0c04b96dc45eea72c59bc6bd90bd853..d0934e0acb05a57d5195f021c5599353f53e9db8 100644 (file)
@@ -989,7 +989,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
        return keymap;
 }
 
-static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cmode)
+static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cmode, bool is_plane)
 {
        if (!(t->flag & T_NO_CONSTRAINT)) {
                int constraint_axis, constraint_plane;
@@ -1042,17 +1042,21 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
                                else {
                                        short orientation = (t->current_orientation != V3D_MANIP_GLOBAL ?
                                                             t->current_orientation : V3D_MANIP_LOCAL);
-                                       if (!(t->modifiers & MOD_CONSTRAINT_PLANE))
+                                       if (is_plane == false) {
                                                setUserConstraint(t, orientation, constraint_axis, msg2);
-                                       else if (t->modifiers & MOD_CONSTRAINT_PLANE)
+                                       }
+                                       else {
                                                setUserConstraint(t, orientation, constraint_plane, msg3);
+                                       }
                                }
                        }
                        else {
-                               if (!(t->modifiers & MOD_CONSTRAINT_PLANE))
+                               if (is_plane == false) {
                                        setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_axis, msg2);
-                               else if (t->modifiers & MOD_CONSTRAINT_PLANE)
+                               }
+                               else {
                                        setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_plane, msg3);
+                               }
                        }
                }
                t->redraw |= TREDRAW_HARD;
@@ -1232,57 +1236,42 @@ int transformEvent(TransInfo *t, const wmEvent *event)
                                break;
                        case TFM_MODAL_AXIS_X:
                                if (!(t->flag & T_NO_CONSTRAINT)) {
-                                       transform_event_xyz_constraint(t, XKEY, cmode);
+                                       transform_event_xyz_constraint(t, XKEY, cmode, false);
                                        t->redraw |= TREDRAW_HARD;
                                        handled = true;
                                }
                                break;
                        case TFM_MODAL_AXIS_Y:
                                if ((t->flag & T_NO_CONSTRAINT) == 0) {
-                                       transform_event_xyz_constraint(t, YKEY, cmode);
+                                       transform_event_xyz_constraint(t, YKEY, cmode, false);
                                        t->redraw |= TREDRAW_HARD;
                                        handled = true;
                                }
                                break;
                        case TFM_MODAL_AXIS_Z:
                                if ((t->flag & (T_NO_CONSTRAINT)) == 0) {
-                                       transform_event_xyz_constraint(t, ZKEY, cmode);
+                                       transform_event_xyz_constraint(t, ZKEY, cmode, false);
                                        t->redraw |= TREDRAW_HARD;
                                        handled = true;
                                }
                                break;
                        case TFM_MODAL_PLANE_X:
                                if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
-                                       if (cmode == 'X') {
-                                               stopConstraint(t);
-                                       }
-                                       else {
-                                               setUserConstraint(t, t->current_orientation, (CON_AXIS1 | CON_AXIS2), IFACE_("locking %s X"));
-                                       }
+                                       transform_event_xyz_constraint(t, XKEY, cmode, true);
                                        t->redraw |= TREDRAW_HARD;
                                        handled = true;
                                }
                                break;
                        case TFM_MODAL_PLANE_Y:
                                if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
-                                       if (cmode == 'Y') {
-                                               stopConstraint(t);
-                                       }
-                                       else {
-                                               setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS2), IFACE_("locking %s Y"));
-                                       }
+                                       transform_event_xyz_constraint(t, YKEY, cmode, true);
                                        t->redraw |= TREDRAW_HARD;
                                        handled = true;
                                }
                                break;
                        case TFM_MODAL_PLANE_Z:
                                if ((t->flag & (T_NO_CONSTRAINT | T_2D_EDIT)) == 0) {
-                                       if (cmode == 'Z') {
-                                               stopConstraint(t);
-                                       }
-                                       else {
-                                               setUserConstraint(t, t->current_orientation, (CON_AXIS0 | CON_AXIS1), IFACE_("locking %s Z"));
-                                       }
+                                       transform_event_xyz_constraint(t, ZKEY, cmode, true);
                                        t->redraw |= TREDRAW_HARD;
                                        handled = true;
                                }