diff options
Diffstat (limited to 'source/blender/editors/transform')
5 files changed, 34 insertions, 21 deletions
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, |