summaryrefslogtreecommitdiffstats
path: root/include/core/Vector2.hpp
diff options
context:
space:
mode:
authorRameshRavone <ramesh.maran443@gmail.com>2019-05-02 09:57:28 +0530
committerRameshRavone <ramesh.maran443@gmail.com>2019-05-02 09:57:28 +0530
commitca85ab244fddeea4f636fbf46db0ce7696ab5cac (patch)
tree73708d68ab013aa1087c6d8c64726d5c7ae11cee /include/core/Vector2.hpp
parente4fb5ca2a56930c13a5edefe5555f221e645670d (diff)
downloadredot-cpp-ca85ab244fddeea4f636fbf46db0ce7696ab5cac.tar.gz
Fix snapped from Vector2
Diffstat (limited to 'include/core/Vector2.hpp')
-rw-r--r--include/core/Vector2.hpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/include/core/Vector2.hpp b/include/core/Vector2.hpp
index 26e9b63..72c5c78 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; }