diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2020-02-17 19:33:29 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2020-02-17 19:33:29 +0300 |
commit | a33b261473e95de8d8d438dbb6aa7afe513fb082 (patch) | |
tree | 3f96f6b3e463141382264f8325c019eb24365044 /source/blender | |
parent | 847bb4c4e0c35a4f617d75a700f79932e310c6db (diff) |
Fix T71455, T73852, T73860: Transform, Redo doesn't work properly in time editors
The redo panel does not consider the position of the mouse.
So it is not possible to know the direction to redo the operator.
The solution is to add a new `direction` parameter that can be
saved and used for redo.
Differential Revision: https://developer.blender.org/D6852
Diffstat (limited to 'source/blender')
6 files changed, 35 insertions, 21 deletions
diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h index d53ad7c4229..c66967a9365 100644 --- a/source/blender/editors/include/ED_transform.h +++ b/source/blender/editors/include/ED_transform.h @@ -153,6 +153,7 @@ int BIF_countTransformOrientation(const struct bContext *C); #define P_GPENCIL_EDIT (1 << 13) #define P_CURSOR_EDIT (1 << 14) #define P_CLNOR_INVALIDATE (1 << 15) +#define P_MOUSE (1 << 16) void Transform_Properties(struct wmOperatorType *ot, int flags); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 13a7ffae141..858096f9a6d 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1637,6 +1637,11 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } + if ((prop = RNA_struct_find_property(op->ptr, "mouse_coordinate_override"))) { + /* Important for redo operations. */ + RNA_property_int_set_array(op->ptr, prop, t->mouse.imval); + } + if (t->flag & T_PROP_EDIT_ALL) { if (t->flag & T_PROP_EDIT) { proportional |= PROP_EDIT_USE; diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index d39ea6f14d7..00f34a20cb6 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1374,6 +1374,24 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve bGPdata *gpd = CTX_data_gpencil_data(C); PropertyRNA *prop; + if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && + RNA_property_is_set(op->ptr, prop)) { + RNA_property_float_get_array(op->ptr, prop, t->center_global); + mul_v3_v3(t->center_global, t->aspect); + t->flag |= T_OVERRIDE_CENTER; + } + + if (op && (prop = RNA_struct_find_property(op->ptr, "mouse_coordinate_override")) && + RNA_property_is_set(op->ptr, prop)) { + RNA_property_int_get_array(op->ptr, prop, t->mval); + } + else if (event) { + copy_v2_v2_int(t->mval, event->mval); + } + else { + zero_v2_int(t->mval); + } + t->depsgraph = CTX_data_depsgraph_pointer(C); t->scene = sce; t->view_layer = view_layer; @@ -1402,21 +1420,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->redraw = TREDRAW_HARD; /* redraw first time */ - if (event) { - t->mouse.imval[0] = event->mval[0]; - t->mouse.imval[1] = event->mval[1]; - } - else { - t->mouse.imval[0] = 0; - t->mouse.imval[1] = 0; - } + t->mouse.imval[0] = t->mval[0]; + t->mouse.imval[1] = t->mval[1]; t->con.imval[0] = t->mouse.imval[0]; t->con.imval[1] = t->mouse.imval[1]; - t->mval[0] = t->mouse.imval[0]; - t->mval[1] = t->mouse.imval[1]; - t->transform = NULL; t->handleEvent = NULL; @@ -1771,13 +1780,6 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve setTransformViewAspect(t, t->aspect); - if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && - RNA_property_is_set(op->ptr, prop)) { - RNA_property_float_get_array(op->ptr, prop, t->center_global); - mul_v3_v3(t->center_global, t->aspect); - t->flag |= T_OVERRIDE_CENTER; - } - setTransformViewMatrices(t); initNumInput(&t->num); } diff --git a/source/blender/editors/transform/transform_mode_timetranslate.c b/source/blender/editors/transform/transform_mode_timetranslate.c index e08aa33b320..3ea97d152ef 100644 --- a/source/blender/editors/transform/transform_mode_timetranslate.c +++ b/source/blender/editors/transform/transform_mode_timetranslate.c @@ -146,7 +146,6 @@ void initTimeTranslate(TransInfo *t) t->state = TRANS_CANCEL; } - t->mode = TFM_TIME_TRANSLATE; t->transform = applyTimeTranslate; initMouseInputMode(t, &t->mouse, INPUT_NONE); diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c index 8a6954f18f7..978b36835cd 100644 --- a/source/blender/editors/transform/transform_mode_translate.c +++ b/source/blender/editors/transform/transform_mode_translate.c @@ -384,7 +384,6 @@ void initTranslation(TransInfo *t) t->state = TRANS_CANCEL; } - t->mode = TFM_TRANSLATION; t->transform = applyTranslation; initMouseInputMode(t, &t->mouse, INPUT_VECTOR); diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 39f6f24eb8d..d3d5d785eac 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -694,6 +694,14 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) RNA_def_property_ui_text(prop, "Center Override", "Force using this center value (when set)"); } + if (flags & P_MOUSE) { + prop = RNA_def_property(ot->srna, "mouse_coordinate_override", PROP_INT, PROP_XYZ); + RNA_def_property_array(prop, 2); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + RNA_def_property_ui_text( + prop, "Mouse Coordinate Override", "Force using this mouse value (when set)"); + } + if ((flags & P_NO_DEFAULTS) == 0) { prop = RNA_def_boolean(ot->srna, "release_confirm", @@ -1239,7 +1247,7 @@ static void TRANSFORM_OT_transform(struct wmOperatorType *ot) Transform_Properties(ot, P_ORIENT_AXIS | P_ORIENT_MATRIX | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | - P_ALIGN_SNAP | P_GPENCIL_EDIT | P_CENTER); + P_ALIGN_SNAP | P_GPENCIL_EDIT | P_CENTER | P_MOUSE); } static int transform_from_gizmo_invoke(bContext *C, |