From e912590bc69c503262f689f01b8d34477802242e Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Perrier Date: Thu, 8 Apr 2021 18:54:35 +0200 Subject: [PATCH] Add Int2 Min/Max. --- Source/Engine/Core/Math/Int2.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Source/Engine/Core/Math/Int2.h b/Source/Engine/Core/Math/Int2.h index 47875a799..236768254 100644 --- a/Source/Engine/Core/Math/Int2.h +++ b/Source/Engine/Core/Math/Int2.h @@ -361,11 +361,31 @@ public: return Int2(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y); } - // Creates vector from maximum components of two vectors + // Returns a vector containing the largest components of the specified vectors + // @param a The first source vector + // @param b The second source vector static Int2 Max(const Int2& a, const Int2& b) { return Int2(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y); } + + // Returns a vector containing the smallest components of the specified vectors + // @param a The first source vector + // @param b The second source vector + // @param result When the method completes, contains an new vector composed of the smallest components of the source vectors + static void Min(const Int2& a, const Int2& b, Int2& result) + { + result = Int2(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y); + } + + // Returns a vector containing the largest components of the specified vectors + // @param a The first source vector + // @param b The second source vector + // @param result When the method completes, contains an new vector composed of the largest components of the source vectors + static void Max(const Int2& a, const Int2& b, Int2& result) + { + result = Int2(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y); + } }; template<>