Merge pull request #371 from NHodgesVFX/VectorBounceReflectFix

Fix Vector's Bounce Reflect
pull/450/head
Marc 2020-08-23 22:04:31 +01:00 committed by GitHub
commit ca800d63c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -193,8 +193,8 @@ struct Vector2 {
return -reflect(p_normal); return -reflect(p_normal);
} }
inline Vector2 reflect(const Vector2 &p_vec) const { inline Vector2 reflect(const Vector2 &p_normal) const {
return p_vec - *this * this->dot(p_vec) * 2.0; return -(*this - p_normal * this->dot(p_normal) * 2.0);
} }
inline real_t angle() const { inline real_t angle() const {

View File

@ -251,8 +251,8 @@ struct Vector3 {
return v; return v;
} }
inline Vector3 reflect(const Vector3 &by) const { inline Vector3 reflect(const Vector3 &p_normal) const {
return by - *this * this->dot(by) * 2.f; return -(*this - p_normal * this->dot(p_normal) * 2.0);
} }
inline Vector3 rotated(const Vector3 &axis, const real_t phi) const { inline Vector3 rotated(const Vector3 &axis, const real_t phi) const {