Transform: default to user-defined orientation
Previously we tried this but reverted (see 64d40c82c3)
because there wasn't a predictable set of keys to use global-space.
Now the keys are swapped:
- 'GX' always transforms in the user defined orientation.
- 'GXX' always transforms in global space.
As before 'GXXX' cycles back to disabling constraints.
This does have a down side that GXX won't be used for local-space
when the user has global space set.
Also, when global is the user-orientation, pressing GX and GXX
does the same thing.
Note: examples here use GX but could be any transform-mode/axis.
This commit is contained in:
@@ -992,13 +992,26 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
|
||||
}
|
||||
}
|
||||
else if (!edit_2d) {
|
||||
if (cmode == axis) {
|
||||
if (t->con.orientation != V3D_MANIP_GLOBAL) {
|
||||
if (cmode != axis) {
|
||||
/* First press, constraint to an axis. */
|
||||
t->orientation.index = 1;
|
||||
const short orientation = t->orientation.types[t->orientation.index];
|
||||
if (is_plane == false) {
|
||||
setUserConstraint(t, orientation, constraint_axis, msg2);
|
||||
}
|
||||
else {
|
||||
setUserConstraint(t, orientation, constraint_plane, msg3);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Successive presses on existing axis, cycle orientation modes. */
|
||||
t->orientation.index = (t->orientation.index + 1) % ARRAY_SIZE(t->orientation.types);
|
||||
|
||||
if (t->orientation.index == 0) {
|
||||
stopConstraint(t);
|
||||
}
|
||||
else {
|
||||
short orientation = (t->current_orientation != V3D_MANIP_GLOBAL ?
|
||||
t->current_orientation : V3D_MANIP_LOCAL);
|
||||
const short orientation = t->orientation.types[t->orientation.index];
|
||||
if (is_plane == false) {
|
||||
setUserConstraint(t, orientation, constraint_axis, msg2);
|
||||
}
|
||||
@@ -1007,14 +1020,6 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (is_plane == false) {
|
||||
setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_axis, msg2);
|
||||
}
|
||||
else {
|
||||
setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_plane, msg3);
|
||||
}
|
||||
}
|
||||
}
|
||||
t->redraw |= TREDRAW_HARD;
|
||||
}
|
||||
@@ -2122,12 +2127,12 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
|
||||
if (t->spacetype == SPACE_VIEW3D) {
|
||||
if ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
|
||||
!RNA_property_is_set(op->ptr, prop) &&
|
||||
(t->current_orientation != V3D_MANIP_CUSTOM_MATRIX))
|
||||
(t->orientation.user != V3D_MANIP_CUSTOM_MATRIX))
|
||||
{
|
||||
t->scene->orientation_type = t->current_orientation;
|
||||
BLI_assert(((t->scene->orientation_index_custom == -1) && (t->custom_orientation == NULL)) ||
|
||||
t->scene->orientation_type = t->orientation.user;
|
||||
BLI_assert(((t->scene->orientation_index_custom == -1) && (t->orientation.custom == NULL)) ||
|
||||
(BKE_scene_transform_orientation_get_index(
|
||||
t->scene, t->custom_orientation) == t->scene->orientation_index_custom));
|
||||
t->scene, t->orientation.custom) == t->scene->orientation_index_custom));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2153,13 +2158,13 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
|
||||
if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
|
||||
/* constraint orientation can be global, even if user selects something else
|
||||
* so use the orientation in the constraint if set */
|
||||
short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->current_orientation;
|
||||
short orientation = (t->con.mode & CON_APPLY) ? t->con.orientation : t->orientation.user;
|
||||
|
||||
if (orientation == V3D_MANIP_CUSTOM) {
|
||||
const int orientation_index_custom = BKE_scene_transform_orientation_get_index(
|
||||
t->scene, t->custom_orientation);
|
||||
t->scene, t->orientation.custom);
|
||||
|
||||
/* Maybe we need a t->con.custom_orientation? Seems like it would always match t->custom_orientation. */
|
||||
/* Maybe we need a t->con.custom_orientation? Seems like it would always match t->orientation.custom. */
|
||||
orientation = V3D_MANIP_CUSTOM + orientation_index_custom;
|
||||
BLI_assert(orientation >= V3D_MANIP_CUSTOM);
|
||||
}
|
||||
@@ -2420,7 +2425,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
||||
t->con.mode |= CON_AXIS2;
|
||||
}
|
||||
|
||||
setUserConstraint(t, t->current_orientation, t->con.mode, "%s");
|
||||
setUserConstraint(t, t->orientation.user, t->con.mode, "%s");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user