diff options
author | Marc <marc.gilleron@gmail.com> | 2020-08-23 22:04:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-23 22:04:31 +0100 |
commit | ca800d63c8ffb0ceabc1a8e9e6e4e74435395c42 (patch) | |
tree | 2438a8a38ff6177932966758e772cd6c8dfc2199 | |
parent | 824f4ef481809fdeed0e6afe09f8b856d71f3b54 (diff) | |
parent | 82476108bab5d59d2fddec97138296d7b9ae4494 (diff) | |
download | redot-cpp-ca800d63c8ffb0ceabc1a8e9e6e4e74435395c42.tar.gz |
Merge pull request #371 from NHodgesVFX/VectorBounceReflectFix
Fix Vector's Bounce Reflect
-rw-r--r-- | include/core/Vector2.hpp | 4 | ||||
-rw-r--r-- | include/core/Vector3.hpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/include/core/Vector2.hpp b/include/core/Vector2.hpp index 2a4c902..b3ef032 100644 --- a/include/core/Vector2.hpp +++ b/include/core/Vector2.hpp @@ -193,8 +193,8 @@ struct Vector2 { return -reflect(p_normal); } - inline Vector2 reflect(const Vector2 &p_vec) const { - return p_vec - *this * this->dot(p_vec) * 2.0; + inline Vector2 reflect(const Vector2 &p_normal) const { + return -(*this - p_normal * this->dot(p_normal) * 2.0); } inline real_t angle() const { diff --git a/include/core/Vector3.hpp b/include/core/Vector3.hpp index bbe8a95..0bfa2d9 100644 --- a/include/core/Vector3.hpp +++ b/include/core/Vector3.hpp @@ -251,8 +251,8 @@ struct Vector3 { return v; } - inline Vector3 reflect(const Vector3 &by) const { - return by - *this * this->dot(by) * 2.f; + inline Vector3 reflect(const Vector3 &p_normal) const { + return -(*this - p_normal * this->dot(p_normal) * 2.0); } inline Vector3 rotated(const Vector3 &axis, const real_t phi) const { |