Fix T87947: Trasnform: Keyboard input uses view orientation
When activated in modal, `translate`, `resize`, `rotate`, `shear` and `edge_rotate_normal` use a different orientation than the set in scene. This orientation needed to match since some of these modes can be switched during operation. The default orientation for these modes was `V3D_ORIENT_VIEW`. And this changed when finishing the `translate` and `resize` to `V3D_ORIENT_GLOBAL`. But this could cause inconsistencies when inputting values from the keyboard. The solution now is to change the orientation when you change the mode. --- Note: Although the user can expect the value entered to reflect the orientation set in the scene, it would require a lot of changes and would not be really useful.
This commit is contained in:
parent
47f4f3c932
commit
ee5bfde9e6
Notes:
blender-bot
2023-03-24 17:05:22 +01:00
Referenced by issue #87947, Regression: Move: keyboard input uses view orientation instead selected
|
@ -1412,25 +1412,6 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
|
|||
ToolSettings *ts = CTX_data_tool_settings(C);
|
||||
PropertyRNA *prop;
|
||||
|
||||
if (!(t->con.mode & CON_APPLY) && (t->flag & T_MODAL) &&
|
||||
ELEM(t->mode, TFM_TRANSLATION, TFM_RESIZE)) {
|
||||
/* When redoing these modes the first time, it's more convenient to save
|
||||
* in the Global orientation. */
|
||||
if (t->mode == TFM_TRANSLATION) {
|
||||
mul_m3_v3(t->spacemtx, t->values_final);
|
||||
}
|
||||
else {
|
||||
float tmat[3][3], sizemat[3][3];
|
||||
size_to_mat3(sizemat, t->values_final);
|
||||
mul_m3_m3m3(tmat, t->spacemtx, sizemat);
|
||||
mat3_to_size(t->values_final, tmat);
|
||||
}
|
||||
|
||||
BLI_assert(t->orient_curr == O_DEFAULT);
|
||||
unit_m3(t->spacemtx);
|
||||
t->orient[0].type = V3D_ORIENT_GLOBAL;
|
||||
}
|
||||
|
||||
/* Save back mode in case we're in the generic operator */
|
||||
if ((prop = RNA_struct_find_property(op->ptr, "mode"))) {
|
||||
RNA_property_enum_set(op->ptr, prop, t->mode);
|
||||
|
|
|
@ -598,6 +598,8 @@ typedef struct TransInfo {
|
|||
* mouse button then.) */
|
||||
bool is_launch_event_tweak;
|
||||
|
||||
bool is_orient_set;
|
||||
|
||||
struct {
|
||||
short type;
|
||||
float matrix[3][3];
|
||||
|
|
|
@ -414,8 +414,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
int orient_type_set = -1;
|
||||
int orient_type_matrix_set = -1;
|
||||
|
||||
bool use_orient_axis = false;
|
||||
|
||||
if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
|
||||
TransformOrientationSlot *orient_slot = &t->scene->orientation_slots[SCE_ORIENT_DEFAULT];
|
||||
orient_type_scene = orient_slot->type;
|
||||
|
@ -435,7 +433,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
|
||||
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
|
||||
t->orient_axis = RNA_property_enum_get(op->ptr, prop);
|
||||
use_orient_axis = true;
|
||||
}
|
||||
|
||||
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
|
||||
|
@ -457,28 +454,23 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
|
||||
if (orient_type_set != -1) {
|
||||
orient_type_default = orient_type_set;
|
||||
t->is_orient_set = true;
|
||||
}
|
||||
else if (orient_type_matrix_set != -1) {
|
||||
orient_type_default = orient_type_set = orient_type_matrix_set;
|
||||
t->is_orient_set = true;
|
||||
}
|
||||
else if (t->con.mode & CON_APPLY) {
|
||||
orient_type_default = orient_type_set = orient_type_scene;
|
||||
}
|
||||
else {
|
||||
orient_type_default = orient_type_scene;
|
||||
if (orient_type_scene == V3D_ORIENT_GLOBAL) {
|
||||
orient_type_set = V3D_ORIENT_LOCAL;
|
||||
}
|
||||
else {
|
||||
orient_type_set = V3D_ORIENT_GLOBAL;
|
||||
}
|
||||
|
||||
if ((t->flag & T_MODAL) && (use_orient_axis || transform_mode_is_changeable(t->mode)) &&
|
||||
(t->mode != TFM_ALIGN)) {
|
||||
orient_type_default = V3D_ORIENT_VIEW;
|
||||
}
|
||||
else {
|
||||
orient_type_default = orient_type_scene;
|
||||
}
|
||||
}
|
||||
|
||||
BLI_assert(!ELEM(-1, orient_type_default, orient_type_set));
|
||||
|
@ -487,9 +479,9 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
orient_type_set = V3D_ORIENT_CUSTOM_MATRIX;
|
||||
}
|
||||
|
||||
orient_types[0] = (short)orient_type_default;
|
||||
orient_types[1] = (short)orient_type_scene;
|
||||
orient_types[2] = (short)orient_type_set;
|
||||
orient_types[O_DEFAULT] = (short)orient_type_default;
|
||||
orient_types[O_SCENE] = (short)orient_type_scene;
|
||||
orient_types[O_SET] = (short)orient_type_set;
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
/* For efficiency, avoid calculating the same orientation twice. */
|
||||
|
@ -506,9 +498,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
|
|||
}
|
||||
}
|
||||
|
||||
/* Set orient_curr to -1 in order to force the update in
|
||||
* `transform_orientations_current_set`. */
|
||||
t->orient_curr = -1;
|
||||
transform_orientations_current_set(t, (t->con.mode & CON_APPLY) ? 2 : 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
|
||||
#include "transform.h"
|
||||
#include "transform_convert.h"
|
||||
#include "transform_orientations.h"
|
||||
#include "transform_snap.h"
|
||||
|
||||
/* Own include. */
|
||||
|
@ -1271,4 +1272,38 @@ void transform_mode_init(TransInfo *t, wmOperator *op, const int mode)
|
|||
* BLI_assert(t->mode == mode); */
|
||||
}
|
||||
|
||||
/**
|
||||
* When in modal nad not set, initializes a default orientation for the mode.
|
||||
*/
|
||||
void transform_mode_default_modal_orientation_set(TransInfo *t, int type)
|
||||
{
|
||||
/* Currently only these types are supported. */
|
||||
BLI_assert(ELEM(type, V3D_ORIENT_GLOBAL, V3D_ORIENT_VIEW));
|
||||
|
||||
if (t->is_orient_set) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(t->flag & T_MODAL)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (t->orient[O_DEFAULT].type == type) {
|
||||
return;
|
||||
}
|
||||
|
||||
RegionView3D *rv3d = NULL;
|
||||
if ((type == V3D_ORIENT_VIEW) && (t->spacetype == SPACE_VIEW3D) && t->region &&
|
||||
(t->region->regiontype == RGN_TYPE_WINDOW)) {
|
||||
rv3d = t->region->regiondata;
|
||||
}
|
||||
|
||||
t->orient[O_DEFAULT].type = ED_transform_calc_orientation_from_type_ex(
|
||||
NULL, t->orient[O_DEFAULT].matrix, NULL, rv3d, NULL, NULL, type, 0);
|
||||
|
||||
if (t->orient_curr == O_DEFAULT) {
|
||||
/* Update Orientation. */
|
||||
transform_orientations_current_set(t, O_DEFAULT);
|
||||
}
|
||||
}
|
||||
/** \} */
|
||||
|
|
|
@ -61,6 +61,7 @@ short getAnimEdit_SnapMode(TransInfo *t);
|
|||
void doAnimEdit_SnapFrame(
|
||||
TransInfo *t, TransData *td, TransData2D *td2d, struct AnimData *adt, short autosnap);
|
||||
void transform_mode_init(TransInfo *t, struct wmOperator *op, const int mode);
|
||||
void transform_mode_default_modal_orientation_set(TransInfo *t, int type);
|
||||
|
||||
/* transform_mode_align.c */
|
||||
void initAlign(TransInfo *t);
|
||||
|
|
|
@ -148,5 +148,7 @@ void initNormalRotation(TransInfo *t)
|
|||
|
||||
storeCustomLNorValue(tc, bm);
|
||||
}
|
||||
|
||||
transform_mode_default_modal_orientation_set(t, V3D_ORIENT_VIEW);
|
||||
}
|
||||
/** \} */
|
||||
|
|
|
@ -194,5 +194,7 @@ void initResize(TransInfo *t)
|
|||
t->num.unit_type[0] = B_UNIT_NONE;
|
||||
t->num.unit_type[1] = B_UNIT_NONE;
|
||||
t->num.unit_type[2] = B_UNIT_NONE;
|
||||
|
||||
transform_mode_default_modal_orientation_set(t, V3D_ORIENT_GLOBAL);
|
||||
}
|
||||
/** \} */
|
||||
|
|
|
@ -249,5 +249,7 @@ void initRotation(TransInfo *t)
|
|||
if (t->flag & T_2D_EDIT) {
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
}
|
||||
|
||||
transform_mode_default_modal_orientation_set(t, V3D_ORIENT_VIEW);
|
||||
}
|
||||
/** \} */
|
||||
|
|
|
@ -232,5 +232,7 @@ void initShear(TransInfo *t)
|
|||
t->num.unit_type[0] = B_UNIT_NONE; /* Don't think we have any unit here? */
|
||||
|
||||
t->flag |= T_NO_CONSTRAINT;
|
||||
|
||||
transform_mode_default_modal_orientation_set(t, V3D_ORIENT_VIEW);
|
||||
}
|
||||
/** \} */
|
||||
|
|
|
@ -470,5 +470,7 @@ void initTranslation(TransInfo *t)
|
|||
t->num.unit_type[1] = B_UNIT_NONE;
|
||||
t->num.unit_type[2] = B_UNIT_NONE;
|
||||
}
|
||||
|
||||
transform_mode_default_modal_orientation_set(t, V3D_ORIENT_GLOBAL);
|
||||
}
|
||||
/** \} */
|
||||
|
|
|
@ -671,10 +671,6 @@ const char *transform_orientations_spacename_get(TransInfo *t, const short orien
|
|||
|
||||
void transform_orientations_current_set(TransInfo *t, const short orient_index)
|
||||
{
|
||||
if (t->orient_curr == orient_index) {
|
||||
return;
|
||||
}
|
||||
|
||||
const short orientation = t->orient[orient_index].type;
|
||||
const char *spacename = transform_orientations_spacename_get(t, orientation);
|
||||
|
||||
|
|
Loading…
Reference in New Issue