diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-06-03 21:20:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-03 21:20:37 +0200 |
commit | a9c6d2a96c484d704391395b73dd6a12c8447635 (patch) | |
tree | b861295ccfe2bd7d7dfbae26d67e491ece39d826 /core/math/vector3i.cpp | |
parent | 932ab0c63737087e98b272e8b47cf642021ff196 (diff) | |
parent | 2e13e3ed4a0f94e5f868cc827d1ba6ad4bed8b35 (diff) |
Merge pull request #45624 from aaronfranke/clamp
Allow clamping vectors and colors in addition to floats and ints
Diffstat (limited to 'core/math/vector3i.cpp')
-rw-r--r-- | core/math/vector3i.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/math/vector3i.cpp b/core/math/vector3i.cpp index 167fa3221d..a82db7f7fc 100644 --- a/core/math/vector3i.cpp +++ b/core/math/vector3i.cpp @@ -48,6 +48,13 @@ int Vector3i::max_axis() const { return x < y ? (y < z ? 2 : 1) : (x < z ? 2 : 0); } +Vector3i Vector3i::clamp(const Vector3i &p_min, const Vector3i &p_max) const { + return Vector3i( + CLAMP(x, p_min.x, p_max.x), + CLAMP(y, p_min.y, p_max.y), + CLAMP(z, p_min.z, p_max.z)); +} + Vector3i::operator String() const { return (itos(x) + ", " + itos(y) + ", " + itos(z)); } |