diff options
author | David Snopek <dsnopek@gmail.com> | 2024-01-04 08:36:30 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-04 08:36:30 -0600 |
commit | dd62b9685fbc9b733a25e26a788b5d7f3212a804 (patch) | |
tree | a755762614f9144fd5a0cc450d6cb0594a1a267f /include/godot_cpp/variant/vector4i.hpp | |
parent | 8d13acca919daa09f2db68e4de36a59199ce6b55 (diff) | |
parent | b733102f4a7fd19e18c86751ea3ec7398571bacf (diff) | |
download | redot-cpp-dd62b9685fbc9b733a25e26a788b5d7f3212a804.tar.gz |
Merge pull request #1347 from Chubercik/vector_method_parity
Add `Vector2i/3i/4i` methods: `distance_to` and `distance_squared_to`
Diffstat (limited to 'include/godot_cpp/variant/vector4i.hpp')
-rw-r--r-- | include/godot_cpp/variant/vector4i.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/godot_cpp/variant/vector4i.hpp b/include/godot_cpp/variant/vector4i.hpp index ccfcf6d..36f2855 100644 --- a/include/godot_cpp/variant/vector4i.hpp +++ b/include/godot_cpp/variant/vector4i.hpp @@ -84,6 +84,9 @@ struct _NO_DISCARD_ Vector4i { _FORCE_INLINE_ int64_t length_squared() const; _FORCE_INLINE_ double length() const; + _FORCE_INLINE_ int64_t distance_squared_to(const Vector4i &p_to) const; + _FORCE_INLINE_ double distance_to(const Vector4i &p_to) const; + _FORCE_INLINE_ void zero(); _FORCE_INLINE_ Vector4i abs() const; @@ -140,6 +143,14 @@ double Vector4i::length() const { return Math::sqrt((double)length_squared()); } +int64_t Vector4i::distance_squared_to(const Vector4i &p_to) const { + return (p_to - *this).length_squared(); +} + +double Vector4i::distance_to(const Vector4i &p_to) const { + return (p_to - *this).length(); +} + Vector4i Vector4i::abs() const { return Vector4i(Math::abs(x), Math::abs(y), Math::abs(z), Math::abs(w)); } |