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,10 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!edit_2d) {
|
else if (!edit_2d) {
|
||||||
if (cmode == axis) {
|
if (cmode != axis) {
|
||||||
if (t->con.orientation != V3D_MANIP_GLOBAL) {
|
/* First press, constraint to an axis. */
|
||||||
stopConstraint(t);
|
t->orientation.index = 1;
|
||||||
}
|
const short orientation = t->orientation.types[t->orientation.index];
|
||||||
else {
|
|
||||||
short orientation = (t->current_orientation != V3D_MANIP_GLOBAL ?
|
|
||||||
t->current_orientation : V3D_MANIP_LOCAL);
|
|
||||||
if (is_plane == false) {
|
if (is_plane == false) {
|
||||||
setUserConstraint(t, orientation, constraint_axis, msg2);
|
setUserConstraint(t, orientation, constraint_axis, msg2);
|
||||||
}
|
}
|
||||||
@@ -1006,13 +1003,21 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, char cm
|
|||||||
setUserConstraint(t, orientation, constraint_plane, msg3);
|
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 {
|
else {
|
||||||
|
const short orientation = t->orientation.types[t->orientation.index];
|
||||||
if (is_plane == false) {
|
if (is_plane == false) {
|
||||||
setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_axis, msg2);
|
setUserConstraint(t, orientation, constraint_axis, msg2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setUserConstraint(t, V3D_MANIP_GLOBAL, constraint_plane, msg3);
|
setUserConstraint(t, orientation, constraint_plane, msg3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2122,12 +2127,12 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
|
|||||||
if (t->spacetype == SPACE_VIEW3D) {
|
if (t->spacetype == SPACE_VIEW3D) {
|
||||||
if ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
|
if ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
|
||||||
!RNA_property_is_set(op->ptr, prop) &&
|
!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;
|
t->scene->orientation_type = t->orientation.user;
|
||||||
BLI_assert(((t->scene->orientation_index_custom == -1) && (t->custom_orientation == NULL)) ||
|
BLI_assert(((t->scene->orientation_index_custom == -1) && (t->orientation.custom == NULL)) ||
|
||||||
(BKE_scene_transform_orientation_get_index(
|
(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"))) {
|
if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) {
|
||||||
/* constraint orientation can be global, even if user selects something else
|
/* constraint orientation can be global, even if user selects something else
|
||||||
* so use the orientation in the constraint if set */
|
* 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) {
|
if (orientation == V3D_MANIP_CUSTOM) {
|
||||||
const int orientation_index_custom = BKE_scene_transform_orientation_get_index(
|
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;
|
orientation = V3D_MANIP_CUSTOM + orientation_index_custom;
|
||||||
BLI_assert(orientation >= V3D_MANIP_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;
|
t->con.mode |= CON_AXIS2;
|
||||||
}
|
}
|
||||||
|
|
||||||
setUserConstraint(t, t->current_orientation, t->con.mode, "%s");
|
setUserConstraint(t, t->orientation.user, t->con.mode, "%s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -503,8 +503,14 @@ typedef struct TransInfo {
|
|||||||
/*************** NEW STUFF *********************/
|
/*************** NEW STUFF *********************/
|
||||||
short launch_event; /* event type used to launch transform */
|
short launch_event; /* event type used to launch transform */
|
||||||
|
|
||||||
short current_orientation;
|
/* Always: 'orientation_types[orientation_index]' */
|
||||||
TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */
|
struct {
|
||||||
|
short user;
|
||||||
|
short index;
|
||||||
|
short types[3];
|
||||||
|
/* this gets used when current_orientation is V3D_MANIP_CUSTOM */
|
||||||
|
TransformOrientation *custom;
|
||||||
|
} orientation;
|
||||||
short gizmo_flag; /* backup from view3d, to restore on end */
|
short gizmo_flag; /* backup from view3d, to restore on end */
|
||||||
|
|
||||||
short prop_mode;
|
short prop_mode;
|
||||||
|
|||||||
@@ -709,7 +709,7 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
|
|||||||
{
|
{
|
||||||
char orientation_str[128];
|
char orientation_str[128];
|
||||||
BLI_snprintf(orientation_str, sizeof(orientation_str), "%s \"%s\"",
|
BLI_snprintf(orientation_str, sizeof(orientation_str), "%s \"%s\"",
|
||||||
IFACE_("custom orientation"), t->custom_orientation->name);
|
IFACE_("custom orientation"), t->orientation.custom->name);
|
||||||
BLI_snprintf(text, sizeof(text), ftext, orientation_str);
|
BLI_snprintf(text, sizeof(text), ftext, orientation_str);
|
||||||
setConstraint(t, t->spacemtx, mode, text);
|
setConstraint(t, t->spacemtx, mode, text);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1395,10 +1395,17 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||||||
t->around = V3D_AROUND_CURSOR;
|
t->around = V3D_AROUND_CURSOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
t->current_orientation = t->scene->orientation_type;
|
t->orientation.user = t->scene->orientation_type;
|
||||||
t->custom_orientation = BKE_scene_transform_orientation_find(
|
t->orientation.custom = BKE_scene_transform_orientation_find(
|
||||||
t->scene, t->scene->orientation_index_custom);
|
t->scene, t->scene->orientation_index_custom);
|
||||||
|
|
||||||
|
t->orientation.index = 0;
|
||||||
|
ARRAY_SET_ITEMS(
|
||||||
|
t->orientation.types,
|
||||||
|
V3D_MANIP_GLOBAL, /* Value isn't used (first index is no constraint). */
|
||||||
|
t->orientation.user,
|
||||||
|
V3D_MANIP_GLOBAL);
|
||||||
|
|
||||||
/* exceptional case */
|
/* exceptional case */
|
||||||
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
|
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
|
||||||
if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) {
|
if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) {
|
||||||
@@ -1489,8 +1496,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||||||
RNA_property_is_set(op->ptr, prop)))
|
RNA_property_is_set(op->ptr, prop)))
|
||||||
{
|
{
|
||||||
RNA_property_float_get_array(op->ptr, prop, &t->spacemtx[0][0]);
|
RNA_property_float_get_array(op->ptr, prop, &t->spacemtx[0][0]);
|
||||||
t->current_orientation = V3D_MANIP_CUSTOM_MATRIX;
|
t->orientation.user = V3D_MANIP_CUSTOM_MATRIX;
|
||||||
t->custom_orientation = 0;
|
t->orientation.custom = 0;
|
||||||
}
|
}
|
||||||
else if (op && ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
|
else if (op && ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
|
||||||
RNA_property_is_set(op->ptr, prop)))
|
RNA_property_is_set(op->ptr, prop)))
|
||||||
@@ -1509,8 +1516,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
t->current_orientation = orientation;
|
t->orientation.user = orientation;
|
||||||
t->custom_orientation = custom_orientation;
|
t->orientation.custom = custom_orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&
|
if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&
|
||||||
|
|||||||
@@ -432,7 +432,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
|
|||||||
Object *ob = CTX_data_active_object(C);
|
Object *ob = CTX_data_active_object(C);
|
||||||
Object *obedit = CTX_data_active_object(C);
|
Object *obedit = CTX_data_active_object(C);
|
||||||
|
|
||||||
switch (t->current_orientation) {
|
switch (t->orientation.user) {
|
||||||
case V3D_MANIP_GLOBAL:
|
case V3D_MANIP_GLOBAL:
|
||||||
unit_m3(t->spacemtx);
|
unit_m3(t->spacemtx);
|
||||||
BLI_strncpy(t->spacename, IFACE_("global"), sizeof(t->spacename));
|
BLI_strncpy(t->spacename, IFACE_("global"), sizeof(t->spacename));
|
||||||
@@ -492,9 +492,9 @@ void initTransformOrientation(bContext *C, TransInfo *t)
|
|||||||
BLI_strncpy(t->spacename, IFACE_("custom"), sizeof(t->spacename));
|
BLI_strncpy(t->spacename, IFACE_("custom"), sizeof(t->spacename));
|
||||||
break;
|
break;
|
||||||
case V3D_MANIP_CUSTOM:
|
case V3D_MANIP_CUSTOM:
|
||||||
BLI_strncpy(t->spacename, t->custom_orientation->name, sizeof(t->spacename));
|
BLI_strncpy(t->spacename, t->orientation.custom->name, sizeof(t->spacename));
|
||||||
|
|
||||||
if (applyTransformOrientation(t->custom_orientation, t->spacemtx, t->spacename)) {
|
if (applyTransformOrientation(t->orientation.custom, t->spacemtx, t->spacename)) {
|
||||||
/* pass */
|
/* pass */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user