summaryrefslogtreecommitdiffstats
path: root/core/math/vector3.h
diff options
context:
space:
mode:
authorChaosus <chaosus89@gmail.com>2019-03-27 13:51:05 +0300
committerChaosus <chaosus89@gmail.com>2019-04-05 17:09:57 +0300
commit55f3bd97a270b691c26d6eda70bc7c0a3ec8f4e8 (patch)
tree2026f7241b7e7670ffb97ceff22962ce90b432f7 /core/math/vector3.h
parent6574c557c962d9e4dd726b494322aea246a0245a (diff)
downloadredot-engine-55f3bd97a270b691c26d6eda70bc7c0a3ec8f4e8.tar.gz
Added direction_to method to vectors
Diffstat (limited to 'core/math/vector3.h')
-rw-r--r--core/math/vector3.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/math/vector3.h b/core/math/vector3.h
index b11838d16e..e9074c5bd4 100644
--- a/core/math/vector3.h
+++ b/core/math/vector3.h
@@ -112,6 +112,7 @@ struct Vector3 {
_FORCE_INLINE_ Vector3 project(const Vector3 &p_b) const;
_FORCE_INLINE_ real_t angle_to(const Vector3 &p_b) const;
+ _FORCE_INLINE_ Vector3 direction_to(const Vector3 &p_b) const;
_FORCE_INLINE_ Vector3 slide(const Vector3 &p_normal) const;
_FORCE_INLINE_ Vector3 bounce(const Vector3 &p_normal) const;
@@ -244,6 +245,12 @@ real_t Vector3::angle_to(const Vector3 &p_b) const {
return Math::atan2(cross(p_b).length(), dot(p_b));
}
+Vector3 Vector3::direction_to(const Vector3 &p_b) const {
+ Vector3 ret(p_b.x - x, p_b.y - y, p_b.z - z);
+ ret.normalize();
+ return ret;
+}
+
/* Operators */
Vector3 &Vector3::operator+=(const Vector3 &p_v) {