diff options
| author | Juan Linietsky | 2014-09-02 23:13:40 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2014-09-02 23:13:40 -0300 |
| commit | 1a2cb755e2d8b9d59178f36702f6dff7235b9088 (patch) | |
| tree | 4a88f47c8b984522e36ac973accb34bdcb00363b /core/math/vector3.h | |
| parent | 89fa70706f9166765c3ac3f799225a467800f065 (diff) | |
| download | godot-1a2cb755e2d8b9d59178f36702f6dff7235b9088.tar.gz godot-1a2cb755e2d8b9d59178f36702f6dff7235b9088.tar.zst godot-1a2cb755e2d8b9d59178f36702f6dff7235b9088.zip | |
Diffstat (limited to 'core/math/vector3.h')
| -rw-r--r-- | core/math/vector3.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h index 959f7cd0a..d2f240882 100644 --- a/core/math/vector3.h +++ b/core/math/vector3.h @@ -111,6 +111,12 @@ struct Vector3 { _FORCE_INLINE_ real_t distance_to(const Vector3& p_b) const; _FORCE_INLINE_ real_t distance_squared_to(const Vector3& p_b) const; + + + _FORCE_INLINE_ Vector3 slide(const Vector3& p_vec) const; + _FORCE_INLINE_ Vector3 reflect(const Vector3& p_vec) const; + + /* Operators */ _FORCE_INLINE_ Vector3& operator+=(const Vector3& p_v); @@ -368,6 +374,16 @@ void Vector3::zero() { x=y=z=0; } +Vector3 Vector3::slide(const Vector3& p_vec) const { + + return p_vec - *this * this->dot(p_vec); +} +Vector3 Vector3::reflect(const Vector3& p_vec) const { + + return p_vec - *this * this->dot(p_vec) * 2.0; + +} + #endif #endif // VECTOR3_H |
