Merge pull request #362 from 2shady4u/Vector2D-GDNative-add-functionalities

Added bounce to vector2.hpp - thanks!
pull/356/head
Bastiaan Olij 2020-01-30 20:52:15 +11:00 committed by GitHub
commit 9a08d1bb40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -176,6 +176,10 @@ struct Vector2 {
return p_vec - *this * this->dot(p_vec);
}
inline Vector2 bounce(const Vector2 &p_normal) const {
return -reflect(p_normal);
}
inline Vector2 reflect(const Vector2 &p_vec) const {
return p_vec - *this * this->dot(p_vec) * 2.0;
}