From fed5805fcce910bc5f7d00cf962e87e543f84f8a Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Perrier Date: Thu, 8 Apr 2021 18:55:07 +0200 Subject: [PATCH] Add Int4 Min/Max. --- Source/Engine/Core/Math/Int4.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Source/Engine/Core/Math/Int4.h b/Source/Engine/Core/Math/Int4.h index 236b34070..8c7f148be 100644 --- a/Source/Engine/Core/Math/Int4.h +++ b/Source/Engine/Core/Math/Int4.h @@ -379,6 +379,40 @@ public: { return Math::Max(X, Y, Z, W); } + + // Returns a vector containing the largest components of the specified vectors + // @param a The first source vector + // @param b The second source vector + static Int4 Max(const Int4& a, const Int4& b) + { + return Int4(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y, a.Z > b.Z ? a.Z : b.Z, a.W > b.W ? a.W : b.W); + } + + // Returns a vector containing the smallest components of the specified vectors + // @param a The first source vector + // @param b The second source vector + static Int4 Min(const Int4& a, const Int4& b) + { + return Int4(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y, a.Z < b.Z ? a.Z : b.Z, a.W < b.W ? a.W : b.W); + } + + // 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 Int4& a, const Int4& b, Int4& result) + { + result = Int4(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y, a.Z > b.Z ? a.Z : b.Z, a.W > b.W ? a.W : b.W); + } + + // 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 Int4& a, const Int4& b, Int4& result) + { + result = Int4(a.X < b.X ? a.X : b.X, a.Y < b.Y ? a.Y : b.Y, a.Z < b.Z ? a.Z : b.Z, a.W < b.W ? a.W : b.W); + } }; template<>