diff options
author | Marc <marc.gilleron@gmail.com> | 2020-09-08 19:31:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-08 19:31:54 +0100 |
commit | c9a740be34438ce999402b7b76304a38daaaa811 (patch) | |
tree | 0b47e2474ccbe1c20d4c952751895bd60082358e /src/core/Vector3.cpp | |
parent | 7fd60d4c666e445f6553824a2ea078511fb03ec3 (diff) | |
parent | 0d1511695d5235fcdc8c566504a4fe6896a29900 (diff) | |
download | redot-cpp-c9a740be34438ce999402b7b76304a38daaaa811.tar.gz |
Merge pull request #451 from Zylann/math
Added Godot's math functions
Diffstat (limited to 'src/core/Vector3.cpp')
-rw-r--r-- | src/core/Vector3.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/core/Vector3.cpp b/src/core/Vector3.cpp index cf95792..879de0b 100644 --- a/src/core/Vector3.cpp +++ b/src/core/Vector3.cpp @@ -67,17 +67,12 @@ void Vector3::rotate(const Vector3 &p_axis, real_t p_phi) { *this = Basis(p_axis, p_phi).xform(*this); } -// this is ugly as well, but hey, I'm a simple man -#define _ugly_stepify(val, step) (step != 0 ? ::floor(val / step + 0.5) * step : val) - void Vector3::snap(real_t p_val) { - x = _ugly_stepify(x, p_val); - y = _ugly_stepify(y, p_val); - z = _ugly_stepify(z, p_val); + x = Math::stepify(x, p_val); + y = Math::stepify(y, p_val); + z = Math::stepify(z, p_val); } -#undef _ugly_stepify - Vector3::operator String() const { return String::num(x) + ", " + String::num(y) + ", " + String::num(z); } |