diff options
author | Nils ANDRÉ-CHANG <nils@nilsand.re> | 2019-09-12 21:28:49 +0100 |
---|---|---|
committer | Nils ANDRÉ-CHANG <nils@nilsand.re> | 2019-09-26 20:36:12 +0100 |
commit | 0024dd7bb5a8a5194ed0283fc506edcd8b4a7737 (patch) | |
tree | 86316cccbf4fda58a275a7451e37fda83465bb20 /editor/plugins/curve_editor_plugin.cpp | |
parent | cafb888361eba08297dd88b18dc71f4d418525c0 (diff) | |
parent | 24e1039eb6fe32115e8d1a62a84965e9be19a2ed (diff) |
Merge branch 'master' into tab_key
Diffstat (limited to 'editor/plugins/curve_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/curve_editor_plugin.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 5d3cef4c34..c2b6031e60 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -167,10 +167,20 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) { _has_undo_data = true; } + const float curve_amplitude = curve.get_max_value() - curve.get_min_value(); + // Snap to "round" coordinates when holding Ctrl. + // Be more precise when holding Shift as well. + float snap_threshold; + if (mm.get_control()) { + snap_threshold = mm.get_shift() ? 0.025 : 0.1; + } else { + snap_threshold = 0.0; + } + if (_selected_tangent == TANGENT_NONE) { // Drag point - Vector2 point_pos = get_world_pos(mpos); + Vector2 point_pos = get_world_pos(mpos).snapped(Vector2(snap_threshold, snap_threshold * curve_amplitude)); int i = curve.set_point_offset(_selected_point, point_pos.x); // The index may change if the point is dragged across another one @@ -188,8 +198,8 @@ void CurveEditor::on_gui_input(const Ref<InputEvent> &p_event) { } else { // Drag tangent - Vector2 point_pos = curve.get_point_position(_selected_point); - Vector2 control_pos = get_world_pos(mpos); + const Vector2 point_pos = curve.get_point_position(_selected_point); + const Vector2 control_pos = get_world_pos(mpos).snapped(Vector2(snap_threshold, snap_threshold * curve_amplitude)); Vector2 dir = (control_pos - point_pos).normalized(); |