From becd1fd1d84b04ea6703510b0b75eea16e1a899a Mon Sep 17 00:00:00 2001 From: Phischermen Date: Mon, 6 Jan 2020 18:43:22 -0800 Subject: [PATCH] Fix issue regarding rotation Canvas items will now rotate correctly no matter what their global scale happens to be. --- editor/plugins/canvas_item_editor_plugin.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 71afddba119..d6d27c11ea1 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1492,7 +1492,9 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref &p_event) { for (List::Element *E = drag_selection.front(); E; E = E->next()) { CanvasItem *canvas_item = E->get(); drag_to = transform.affine_inverse().xform(m->get_position()); - canvas_item->_edit_set_rotation(snap_angle(canvas_item->_edit_get_rotation() + (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), canvas_item->_edit_get_rotation())); + //Rotate the opposite way if the canvas item's compounded scale has an uneven number of negative elements + bool opposite = (canvas_item->get_global_transform().get_scale().sign().dot(canvas_item->get_transform().get_scale().sign()) == 0); + canvas_item->_edit_set_rotation(snap_angle(canvas_item->_edit_get_rotation() + (opposite ? -1 : 1) * (drag_from - drag_rotation_center).angle_to(drag_to - drag_rotation_center), canvas_item->_edit_get_rotation())); viewport->update(); } return true;