From 2e13e3ed4a0f94e5f868cc827d1ba6ad4bed8b35 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Mon, 1 Feb 2021 00:10:52 -0500 Subject: Allow clamping vectors and colors --- core/math/vector3i.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'core/math/vector3i.cpp') 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)); } -- cgit v1.2.3