Merge pull request #34879 from Phischermen/canvas-item-editor-local-space-mode

Fix issue regarding rotating Canvas Items in editor
This commit is contained in:
Rémi Verschelde 2020-01-16 23:10:41 +01:00 committed by GitHub
commit 05e042b06f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1492,7 +1492,9 @@ bool CanvasItemEditor::_gui_input_rotate(const Ref<InputEvent> &p_event) {
for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) { for (List<CanvasItem *>::Element *E = drag_selection.front(); E; E = E->next()) {
CanvasItem *canvas_item = E->get(); CanvasItem *canvas_item = E->get();
drag_to = transform.affine_inverse().xform(m->get_position()); 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(); viewport->update();
} }
return true; return true;