diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-03-10 10:17:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-10 10:17:42 +0100 |
commit | 1500e40ccf88b0bca34667e3113e4d6c18b3de29 (patch) | |
tree | be644012eb91dd662896929311989e0d276ccf49 | |
parent | 1f6c9328dd167077320917974619aa69ec28a6e5 (diff) | |
parent | 97a07bada78be2411d5f57e704fd440da91bca21 (diff) |
Merge pull request #36887 from MCrafterzz/relativeSnap
Made snap relative work on rotation as well
-rw-r--r-- | editor/plugins/canvas_item_editor_plugin.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 4bfe633494..5629e3854d 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<InputEvent> &p_ev) { |