diff options
| author | NHodgesVFX <test@test.com> | 2020-02-04 16:33:43 -0500 |
|---|---|---|
| committer | NHodgesVFX <test@test.com> | 2020-02-06 18:38:39 -0500 |
| commit | a2e6f7a5efab2fcf765429aa6985a6faca750c74 (patch) | |
| tree | c17efcdc30adfb30f17eb221afd232ba8f0bb680 /include/core | |
| parent | aba8766618c6aa40c6f7b40b513e8e47cfa807f4 (diff) | |
| download | redot-cpp-a2e6f7a5efab2fcf765429aa6985a6faca750c74.tar.gz | |
Fix Vector's Bounce Reflect
Fixes Vector 2 and 3 bounce and reflect methods to match gdscript
Co-Authored-By: Bruno Campos <brunocu@msn.com>
Move calculation to reflect
fix commit
squash
fix style
Diffstat (limited to 'include/core')
| -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 99ac60f..5364330 100644 --- a/include/core/Vector2.hpp +++ b/include/core/Vector2.hpp @@ -180,8 +180,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 2d78f21..8b39113 100644 --- a/include/core/Vector3.hpp +++ b/include/core/Vector3.hpp @@ -238,8 +238,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.f); } inline Vector3 rotated(const Vector3 &axis, const real_t phi) const { |
