From 97a07bada78be2411d5f57e704fd440da91bca21 Mon Sep 17 00:00:00 2001 From: Marcus Elg Date: Sat, 7 Mar 2020 17:47:24 +0100 Subject: Made snap relative work on rotation as well --- editor/plugins/canvas_item_editor_plugin.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index af7f8cf5d6..7c8f51a03e 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -462,7 +462,15 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, unsig } float CanvasItemEditor::snap_angle(float p_target, float p_start) const { - return (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) ? Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset : p_target; + if (((smart_snap_active || snap_rotation) ^ Input::get_singleton()->is_key_pressed(KEY_CONTROL)) && snap_rotation_step != 0) { + if (snap_relative) { + return Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset + (p_start - (int)(p_start / snap_rotation_step) * snap_rotation_step); + } else { + return Math::stepify(p_target - snap_rotation_offset, snap_rotation_step) + snap_rotation_offset; + } + } else { + return p_target; + } } void CanvasItemEditor::_unhandled_key_input(const Ref &p_ev) { -- cgit v1.2.3