summaryrefslogtreecommitdiffstats
path: root/editor/plugins/polygon_2d_editor_plugin.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-10-22 12:06:00 +0200
committerGitHub <noreply@github.com>2017-10-22 12:06:00 +0200
commit99c8a8c7b1da2831a2d6f7fb3b78bd9f68272e9f (patch)
treef7810fc7be2c4eee2b0ec3bf4795f1930fd6f7ce /editor/plugins/polygon_2d_editor_plugin.cpp
parentbc667aeada757463fbb562eb262d404968f0ca37 (diff)
parent2e22c07f4261625834bd0d16aa5e09005666ab14 (diff)
downloadredot-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.cpp8
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;