diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2017-10-22 12:06:00 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-22 12:06:00 +0200 |
| commit | 99c8a8c7b1da2831a2d6f7fb3b78bd9f68272e9f (patch) | |
| tree | f7810fc7be2c4eee2b0ec3bf4795f1930fd6f7ce /editor/plugins/polygon_2d_editor_plugin.cpp | |
| parent | bc667aeada757463fbb562eb262d404968f0ca37 (diff) | |
| parent | 2e22c07f4261625834bd0d16aa5e09005666ab14 (diff) | |
| download | redot-engine-99c8a8c7b1da2831a2d6f7fb3b78bd9f68272e9f.tar.gz | |
Merge pull request #11401 from SaracenOne/snapped_drag
Added snapping to spatial drag and drop.
Diffstat (limited to 'editor/plugins/polygon_2d_editor_plugin.cpp')
| -rw-r--r-- | editor/plugins/polygon_2d_editor_plugin.cpp | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index 0e8c13b067..a525983c75 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -437,14 +437,10 @@ void Polygon2DEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_set_snap_step_y"), &Polygon2DEditor::_set_snap_step_y); } -inline float _snap_scalar(float p_offset, float p_step, float p_target) { - return p_step != 0 ? Math::stepify(p_target - p_offset, p_step) + p_offset : p_target; -} - Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const { if (use_snap) { - p_target.x = _snap_scalar(snap_offset.x * uv_draw_zoom - uv_draw_ofs.x, snap_step.x * uv_draw_zoom, p_target.x); - p_target.y = _snap_scalar(snap_offset.y * uv_draw_zoom - uv_draw_ofs.y, snap_step.y * uv_draw_zoom, p_target.y); + p_target.x = Math::snap_scalar(snap_offset.x * uv_draw_zoom - uv_draw_ofs.x, snap_step.x * uv_draw_zoom, p_target.x); + p_target.y = Math::snap_scalar(snap_offset.y * uv_draw_zoom - uv_draw_ofs.y, snap_step.y * uv_draw_zoom, p_target.y); } return p_target; |
