diff options
author | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-03-03 14:37:52 +0100 |
---|---|---|
committer | A Thousand Ships <96648715+AThousandShips@users.noreply.github.com> | 2024-05-02 10:31:13 +0200 |
commit | 308dbb8c6359589ce7411027cecd777938e40bd7 (patch) | |
tree | 80a8cf2eff0d0c1ef1e7e0913b8616e0ee4e376a /core/math/vector4i.h | |
parent | f91db3dc58f1d6a0cb63d591515183b5a45cd3ba (diff) | |
download | redot-engine-308dbb8c6359589ce7411027cecd777938e40bd7.tar.gz |
[Core] Add scalar versions of `Vector*` `min/max/clamp/snap(ped)`
Convenience for a number of cases operating on single values
Diffstat (limited to 'core/math/vector4i.h')
-rw-r--r-- | core/math/vector4i.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/math/vector4i.h b/core/math/vector4i.h index 5a96d98d18..8a9c580bc1 100644 --- a/core/math/vector4i.h +++ b/core/math/vector4i.h @@ -75,10 +75,18 @@ struct _NO_DISCARD_ Vector4i { return Vector4i(MIN(x, p_vector4i.x), MIN(y, p_vector4i.y), MIN(z, p_vector4i.z), MIN(w, p_vector4i.w)); } + Vector4i mini(int32_t p_scalar) const { + return Vector4i(MIN(x, p_scalar), MIN(y, p_scalar), MIN(z, p_scalar), MIN(w, p_scalar)); + } + Vector4i max(const Vector4i &p_vector4i) const { return Vector4i(MAX(x, p_vector4i.x), MAX(y, p_vector4i.y), MAX(z, p_vector4i.z), MAX(w, p_vector4i.w)); } + Vector4i maxi(int32_t p_scalar) const { + return Vector4i(MAX(x, p_scalar), MAX(y, p_scalar), MAX(z, p_scalar), MAX(w, p_scalar)); + } + _FORCE_INLINE_ int64_t length_squared() const; _FORCE_INLINE_ double length() const; @@ -90,7 +98,9 @@ struct _NO_DISCARD_ Vector4i { _FORCE_INLINE_ Vector4i abs() const; _FORCE_INLINE_ Vector4i sign() const; Vector4i clamp(const Vector4i &p_min, const Vector4i &p_max) const; + Vector4i clampi(int32_t p_min, int32_t p_max) const; Vector4i snapped(const Vector4i &p_step) const; + Vector4i snappedi(int32_t p_step) const; /* Operators */ |