From ca85ab244fddeea4f636fbf46db0ce7696ab5cac Mon Sep 17 00:00:00 2001 From: RameshRavone Date: Thu, 2 May 2019 09:57:28 +0530 Subject: [PATCH] Fix snapped from Vector2 --- include/core/Vector2.hpp | 6 +++++- src/core/Vector2.cpp | 6 ------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/core/Vector2.hpp b/include/core/Vector2.hpp index 26e9b634..72c5c789 100644 --- a/include/core/Vector2.hpp +++ b/include/core/Vector2.hpp @@ -208,7 +208,11 @@ struct Vector2 { return Vector2(::floor(x), ::floor(y)); } - inline Vector2 snapped(const Vector2 &p_by) const; + inline Vector2 snapped(const Vector2 &p_by) const { + return Vector2( + p_by.x != 0 ? ::floor(x / p_by.x + 0.5) * p_by.x : x, + p_by.y != 0 ? ::floor(y / p_by.y + 0.5) * p_by.y : y); + } inline real_t aspect() const { return width / height; } diff --git a/src/core/Vector2.cpp b/src/core/Vector2.cpp index 2da6f479..44dc001f 100644 --- a/src/core/Vector2.cpp +++ b/src/core/Vector2.cpp @@ -54,12 +54,6 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c return out; } -Vector2 Vector2::snapped(const Vector2 &p_by) const { - return Vector2( - p_by.x != 0 ? ::floor(x / p_by.x + 0.5) * p_by.x : x, - p_by.y != 0 ? ::floor(y / p_by.y + 0.5) * p_by.y : y); -} - Vector2::operator String() const { return String::num(x) + ", " + String::num(y); }