From 866105631e128add73c042e3273259762fb12926 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Perrier Date: Thu, 8 Apr 2021 18:50:59 +0200 Subject: [PATCH] Add Int4.cpp. --- .../Core/Math/{VectorInt.cpp => Int4.cpp} | 67 +++++++++++-------- 1 file changed, 38 insertions(+), 29 deletions(-) rename Source/Engine/Core/Math/{VectorInt.cpp => Int4.cpp} (56%) diff --git a/Source/Engine/Core/Math/VectorInt.cpp b/Source/Engine/Core/Math/Int4.cpp similarity index 56% rename from Source/Engine/Core/Math/VectorInt.cpp rename to Source/Engine/Core/Math/Int4.cpp index 300343da5..a8f6be236 100644 --- a/Source/Engine/Core/Math/VectorInt.cpp +++ b/Source/Engine/Core/Math/Int4.cpp @@ -1,42 +1,51 @@ // Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. -#include "VectorInt.h" +#include "Int2.h" +#include "Int3.h" +#include "Int4.h" #include "Vector2.h" #include "Vector3.h" #include "Vector4.h" #include "Engine/Core/Types/String.h" -const Int2 Int2::Zero(0); -const Int2 Int2::One(1); - -Int2::Int2(const Vector2& v) - : X(static_cast(v.X)) - , Y(static_cast(v.Y)) -{ -} - -String Int2::ToString() const -{ - return String::Format(TEXT("{}"), *this); -} - -const Int3 Int3::Zero(0); -const Int3 Int3::One(1); - -Int3::Int3(const Vector3& v) - : X(static_cast(v.X)) - , Y(static_cast(v.Y)) - , Z(static_cast(v.Z)) -{ -} - -String Int3::ToString() const -{ - return String::Format(TEXT("{}"), *this); -} +static_assert(sizeof(Int4) == 16, "Invalid Int4 type size."); const Int4 Int4::Zero(0); const Int4 Int4::One(1); +const Int4 Int4::Minimum(MIN_int32); +const Int4 Int4::Maximum(MAX_int32); + +Int4::Int4(const Int2& xy, int32 z, int32 w) + : X(xy.X) + , Y(xy.Y) + , Z(z) + , W(w) +{ +} + +Int4::Int4(const Int3& xyz, int32 w) + : X(xyz.X) + , Y(xyz.Y) + , Z(xyz.Z) + , W(w) +{ +} + +Int4::Int4(const Vector2& v, int32 z, int32 w) + : X(static_cast(v.X)) + , Y(static_cast(v.Y)) + , Z(z) + , W(w) +{ +} + +Int4::Int4(const Vector3& v, int32 w) + : X(static_cast(v.X)) + , Y(static_cast(v.Y)) + , Z(static_cast(v.Z)) + , W(w) +{ +} Int4::Int4(const Vector4& v) : X(static_cast(v.X))