Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2018-11-28 02:01:16 +0300
committerCampbell Barton <ideasman42@gmail.com>2018-11-28 02:15:02 +0300
commit6491d50d02b7c93b4955fe05dae62930f3a76ce1 (patch)
tree31b1513e33760b716a16366266dbd4e7f37bdc32 /source/blender/editors
parent437d7d7cb9df3132d2e935f2b500f8669c17c4cc (diff)
Transform: default to user-defined orientation
Previously we tried this but reverted (see 64d40c82c324) 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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/transform/transform.c45
-rw-r--r--source/blender/editors/transform/transform.h10
-rw-r--r--source/blender/editors/transform/transform_constraints.c2
-rw-r--r--source/blender/editors/transform/transform_generics.c19
-rw-r--r--source/blender/editors/transform/transform_orientations.c6
5 files changed, 50 insertions, 32 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index fed5f392bb7..bd2a8f04996 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -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");
}
}
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index d777b034e76..8101833a609 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -503,8 +503,14 @@ typedef struct TransInfo {
/*************** NEW STUFF *********************/
short launch_event; /* event type used to launch transform */
- short current_orientation;
- TransformOrientation *custom_orientation; /* this gets used when current_orientation is V3D_MANIP_CUSTOM */
+ /* Always: 'orientation_types[orientation_index]' */
+ 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 prop_mode;
diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c
index 22d616572c1..fe997b77a31 100644
--- a/source/blender/editors/transform/transform_constraints.c
+++ b/source/blender/editors/transform/transform_constraints.c
@@ -709,7 +709,7 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
{
char orientation_str[128];
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);
setConstraint(t, t->spacemtx, mode, text);
break;
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 65c8c50e746..9f739765d9c 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1395,10 +1395,17 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
t->around = V3D_AROUND_CURSOR;
}
- t->current_orientation = t->scene->orientation_type;
- t->custom_orientation = BKE_scene_transform_orientation_find(
+ t->orientation.user = t->scene->orientation_type;
+ t->orientation.custom = BKE_scene_transform_orientation_find(
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 */
if (t->around == V3D_AROUND_LOCAL_ORIGINS) {
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_float_get_array(op->ptr, prop, &t->spacemtx[0][0]);
- t->current_orientation = V3D_MANIP_CUSTOM_MATRIX;
- t->custom_orientation = 0;
+ t->orientation.user = V3D_MANIP_CUSTOM_MATRIX;
+ t->orientation.custom = 0;
}
else if (op && ((prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) &&
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->custom_orientation = custom_orientation;
+ t->orientation.user = orientation;
+ t->orientation.custom = custom_orientation;
}
if (op && ((prop = RNA_struct_find_property(op->ptr, "release_confirm")) &&
diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c
index 08f94cdfb2d..5be23594afd 100644
--- a/source/blender/editors/transform/transform_orientations.c
+++ b/source/blender/editors/transform/transform_orientations.c
@@ -432,7 +432,7 @@ void initTransformOrientation(bContext *C, TransInfo *t)
Object *ob = CTX_data_active_object(C);
Object *obedit = CTX_data_active_object(C);
- switch (t->current_orientation) {
+ switch (t->orientation.user) {
case V3D_MANIP_GLOBAL:
unit_m3(t->spacemtx);
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));
break;
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 */
}
else {