summaryrefslogtreecommitdiff
path: root/core/math/vector3i.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-06-03 21:20:37 +0200
committerGitHub <noreply@github.com>2021-06-03 21:20:37 +0200
commita9c6d2a96c484d704391395b73dd6a12c8447635 (patch)
treeb861295ccfe2bd7d7dfbae26d67e491ece39d826 /core/math/vector3i.cpp
parent932ab0c63737087e98b272e8b47cf642021ff196 (diff)
parent2e13e3ed4a0f94e5f868cc827d1ba6ad4bed8b35 (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.cpp7
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));
}