Fix T76919: Wrong orientation when changing translate to rotate

During the refactor of the transform operations, in an attempt to
maintain previous behavior, the default orientation of the translate
and resize operations became `Global` and the rotate operation became
`View`.

Now the default is always `View`, and on redo, the translate and rotate
operations are saved as `Global`.
This commit is contained in:
Germano Cavalcante 2020-05-20 16:22:10 -03:00
parent 29afadcb15
commit 600fd1c6f0
Notes: blender-bot 2023-02-14 11:42:40 +01:00
Referenced by commit 0e75aa44fb, Fix T78304: Scaling without a constraint axis shows wrong parameters in Adjust Last operator panel
Referenced by issue #78304, Scaling without a constraint axis shows wrong parameters in Adjust Last operator panel
Referenced by issue #76919, Rotation direction is inverted after SHIFT+D and R
4 changed files with 31 additions and 22 deletions

View File

@ -1615,6 +1615,17 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
int proportional = 0;
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
* the Global orientation. */
mul_m3_v3(t->spacemtx, t->values_final);
unit_m3(t->spacemtx);
BLI_assert(t->orientation.index == 0);
t->orientation.types[0] = 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);

View File

@ -519,6 +519,7 @@ typedef struct TransInfo {
/** orientation matrix of the current space. */
float spacemtx[3][3];
float spacemtx_inv[3][3];
/** name of the current space, MAX_NAME. */
char spacename[64];

View File

@ -1660,15 +1660,11 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve
orient_type_scene += index_custom;
}
short orient_type_default = V3D_ORIENT_GLOBAL;
short orient_type_default = V3D_ORIENT_VIEW;
short orient_type_constraint[2];
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis"))) {
t->orient_axis = RNA_property_enum_get(op->ptr, prop);
/* For transfor modes that require "orient_axis" use
* `V3D_ORIENT_VIEW` as default. */
orient_type_default = V3D_ORIENT_VIEW;
}
if (op && (prop = RNA_struct_find_property(op->ptr, "orient_axis_ortho"))) {
t->orient_axis_ortho = RNA_property_enum_get(op->ptr, prop);

View File

@ -318,40 +318,39 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
{
char str[UI_MAX_DRAW_STR];
float global_dir[3];
if (t->flag & T_INPUT_IS_VALUES_FINAL) {
copy_v3_v3(t->values_final, t->values);
mul_v3_m3v3(global_dir, t->spacemtx, t->values);
}
else {
copy_v3_v3(t->values_final, t->values);
copy_v3_v3(global_dir, t->values);
if ((t->con.mode & CON_APPLY) == 0) {
snapGridIncrement(t, t->values_final);
snapGridIncrement(t, global_dir);
}
if (applyNumInput(&t->num, t->values_final)) {
removeAspectRatio(t, t->values_final);
if (applyNumInput(&t->num, global_dir)) {
removeAspectRatio(t, global_dir);
}
applySnapping(t, t->values_final);
applySnapping(t, global_dir);
}
if (t->con.mode & CON_APPLY) {
float values_final[3];
copy_v3_v3(values_final, t->values_final);
t->con.applyVec(t, NULL, NULL, values_final, t->values_final);
headerTranslation(t, t->values_final, str);
float in[3];
copy_v3_v3(in, global_dir);
t->con.applyVec(t, NULL, NULL, in, global_dir);
headerTranslation(t, global_dir, str);
}
else {
headerTranslation(t, t->values_final, str);
headerTranslation(t, global_dir, str);
}
/* don't use 't->values' now on */
applyTranslationValue(t, t->values_final);
applyTranslationValue(t, global_dir);
/* evil hack - redo translation if clipping needed */
if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values_final, 0)) {
applyTranslationValue(t, t->values_final);
if (t->flag & T_CLIP_UV && clipUVTransform(t, global_dir, 0)) {
applyTranslationValue(t, global_dir);
/* In proportional edit it can happen that */
/* vertices in the radius of the brush end */
@ -362,8 +361,10 @@ static void applyTranslation(TransInfo *t, const int UNUSED(mval[2]))
}
}
recalcData(t);
/* Set the redo value. */
mul_v3_m3v3(t->values_final, t->spacemtx_inv, global_dir);
recalcData(t);
ED_area_status_text(t->area, str);
}