From 388b9162469650c7b0523c2fb9c88bbe2dee1567 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Thu, 24 Sep 2020 19:16:41 -0300 Subject: Fix T80937: Changing the contrain axis does not return to the scene orientation This was the behavior in old versions of blender. During a transformation operation, when pressing a contrain key, the chosen orientation is that of the scene. If you press the same key, the orientation changes to Global or Local. However, if you choose another contrain axis with the orientation changed, the orientation does not return to the set for the scene. It remains Global or Local. Now when changing a contrain axis, no matter what the current orientation is, it always returns to the scene orientation. --- source/blender/editors/transform/transform.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'source/blender/editors/transform/transform.c') diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index bc08cb91c0d..ab24bbb35d4 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -755,27 +755,22 @@ static void transform_event_xyz_constraint(TransInfo *t, short key_type, bool is stopConstraint(t); } else { - setUserConstraint(t, V3D_ORIENT_GLOBAL, constraint_axis, msg1); + setUserConstraint(t, constraint_axis, msg1); } } else if (!edit_2d) { + short orient_index = 1; if (t->orient_curr == 0 || ELEM(cmode, '\0', axis)) { /* Successive presses on existing axis, cycle orientation modes. */ - t->orient_curr = (short)((t->orient_curr + 1) % (int)ARRAY_SIZE(t->orient)); - transform_orientations_current_set(t, t->orient_curr); + orient_index = (short)((t->orient_curr + 1) % (int)ARRAY_SIZE(t->orient)); } - if (t->orient_curr == 0) { + transform_orientations_current_set(t, orient_index); + if (orient_index == 0) { stopConstraint(t); } else { - const short orientation = t->orient[t->orient_curr].type; - if (is_plane == false) { - setUserConstraint(t, orientation, constraint_axis, msg2); - } - else { - setUserConstraint(t, orientation, constraint_plane, msg3); - } + setUserConstraint(t, constraint_axis, is_plane ? msg3 : msg2); } } t->redraw |= TREDRAW_HARD; @@ -1717,10 +1712,6 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve initTransInfo(C, t, op, event); - /* Use the custom orientation when it is set. */ - short orient_index = t->orient[0].type == V3D_ORIENT_CUSTOM_MATRIX ? 0 : t->orient_curr; - transform_orientations_current_set(t, orient_index); - if (t->spacetype == SPACE_VIEW3D) { t->draw_handle_apply = ED_region_draw_cb_activate( t->region->type, drawTransformApply, t, REGION_DRAW_PRE_VIEW); @@ -1868,7 +1859,7 @@ bool initTransform(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve /* Constraint init from operator */ if (t->con.mode & CON_APPLY) { - setUserConstraint(t, t->orient[t->orient_curr].type, t->con.mode, "%s"); + setUserConstraint(t, t->con.mode, "%s"); } /* Don't write into the values when non-modal because they are already set from operator redo -- cgit v1.2.3