diff --git a/Engine/Source/Runtime/Core/public/Math/Detail/IntVector3Decl.inl b/Engine/Source/Runtime/Core/public/Math/Detail/IntVector3Decl.inl index 5ab529e..1e4dbd0 100644 --- a/Engine/Source/Runtime/Core/public/Math/Detail/IntVector3Decl.inl +++ b/Engine/Source/Runtime/Core/public/Math/Detail/IntVector3Decl.inl @@ -2,6 +2,8 @@ #include "Core/public/Math/Boilerplate.h" +#include "../IntVector3.hpp" + namespace Phanes::Core::Math::Detail { template @@ -56,31 +58,46 @@ namespace Phanes::Core::Math::Detail template struct construct_ivec3 { - static constexpr void map(Phanes::Core::Math::TIntVector2& v1, const TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& v1, const TIntVector3& v2) { v1.x = v2.x; v1.y = v2.y; v1.z = v2.z; + v1.w = (T)0; } - static constexpr void map(Phanes::Core::Math::TIntVector2& v1, T s) + static constexpr void map(Phanes::Core::Math::TIntVector3& v1, T s) { v1.x = s; v1.y = s; + v1.z = s; + v1.w = (T)0; } - static constexpr void map(Phanes::Core::Math::TIntVector2& v1, T x, T y) + static constexpr void map(Phanes::Core::Math::TIntVector3& v1, T x, T y, T z) { v1.x = x; v1.y = y; + v1.y = z; + v1.w = (T)0; } - static constexpr void map(Phanes::Core::Math::TIntVector2& v1, const T* comp) + static constexpr void map(Phanes::Core::Math::TIntVector3& v1, const T* comp) { v1.x = comp[0]; v1.y = comp[1]; + v1.z = comp[2]; + v1.w = (T)0; + } + + static constexpr void map(Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector2& v2, const T s) + { + v1.x = v2.x; + v1.y = v2.y; + v1.z = s; + v1.w = (T)0; } }; @@ -88,16 +105,18 @@ namespace Phanes::Core::Math::Detail template struct compute_ivec3_add { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x + v2.x; r.y = v1.y + v2.y; + r.z = v1.z + v2.z; } - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) { r.x = v1.x + s; r.y = v1.y + s; + r.z = v1.z + s; } }; @@ -105,16 +124,18 @@ namespace Phanes::Core::Math::Detail template struct compute_ivec3_sub { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x - v2.x; r.y = v1.y - v2.y; + r.z = v1.z - v2.z; } - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) { r.x = v1.x - s; r.y = v1.y - s; + r.z = v1.z - s; } }; @@ -122,16 +143,18 @@ namespace Phanes::Core::Math::Detail template struct compute_ivec3_mul { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x * v2.x; r.y = v1.y * v2.y; + r.z = v1.z * v2.z; } - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) { r.x = v1.x * s; r.y = v1.y * s; + r.z = v1.z * s; } }; @@ -139,74 +162,82 @@ namespace Phanes::Core::Math::Detail template struct compute_ivec3_div { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x / v2.x; r.y = v1.y / v2.y; + r.z = v1.z / v2.z; } - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) { s = (T)1.0 / s; r.x = v1.x * s; r.y = v1.y * s; + r.z = v1.z * s; } }; template struct compute_ivec3_mod { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x % v2.x; r.y = v1.y % v2.y; + r.z = v1.z % v2.z; } - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) { r.x = v1.x % s; r.y = v1.y % s; + r.z = v1.z % s; } }; template struct compute_ivec3_eq { - static constexpr bool map(const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr bool map(const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { return (Phanes::Core::Math::Abs(v1.x - v2.x) < P_FLT_INAC && - Phanes::Core::Math::Abs(v1.y - v2.y) < P_FLT_INAC); + Phanes::Core::Math::Abs(v1.y - v2.y) < P_FLT_INAC && + Phanes::Core::Math::Abs(v1.z - v2.z) < P_FLT_INAC); } }; template struct compute_ivec3_ieq { - static constexpr bool map(const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr bool map(const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { return (Phanes::Core::Math::Abs(v1.x - v2.x) > P_FLT_INAC || - Phanes::Core::Math::Abs(v1.y - v2.y) > P_FLT_INAC); + Phanes::Core::Math::Abs(v1.y - v2.y) > P_FLT_INAC || + Phanes::Core::Math::Abs(v1.y - v2.y) > P_FLT_INAC); } }; template struct compute_ivec3_inc { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1) { r.x = v1.x + 1; r.y = v1.y + 1; + r.z = v1.z + 1; } }; template struct compute_ivec3_dec { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1) { r.x = v1.x - 1; r.y = v1.y - 1; + r.z = v1.z - 1; } }; @@ -214,66 +245,101 @@ namespace Phanes::Core::Math::Detail template struct compute_ivec3_and { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x & v2.x; r.y = v1.y & v2.y; + r.z = v1.z & v2.y; } - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, T s) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) { r.x = v1.x & s; r.y = v1.y & s; + r.z = v1.z & s; } }; template struct compute_ivec3_or { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x | v2.x; r.y = v1.y | v2.y; + r.z = v1.z | v2.z; + } + + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) + { + r.x = v1.x | s; + r.y = v1.y | s; + r.z = v1.z | s; } }; template struct compute_ivec3_xor { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x ^ v2.x; r.y = v1.y ^ v2.y; + r.z = v1.z ^ v2.z; + } + + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) + { + r.x = v1.x ^ s; + r.y = v1.y ^ s; + r.z = v1.z ^ s; } }; template struct compute_ivec3_left_shift { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x << v2.x; r.y = v1.y << v2.y; + r.z = v1.z << v2.z; + } + + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) + { + r.x = v1.x << s; + r.y = v1.y << s; + r.z = v1.z << s; } }; template struct compute_ivec3_right_shift { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, const Phanes::Core::Math::TIntVector3& v2) { r.x = v1.x >> v2.x; r.y = v1.y >> v2.y; + r.z = v1.z >> v2.z; + } + + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1, T s) + { + r.x = v1.x >> s; + r.y = v1.y >> s; + r.z = v1.z >> s; } }; template struct compute_ivec3_bnot { - static constexpr void map(Phanes::Core::Math::TIntVector2& r, const Phanes::Core::Math::TIntVector2& v1) + static constexpr void map(Phanes::Core::Math::TIntVector3& r, const Phanes::Core::Math::TIntVector3& v1) { r.x = ~v1.x; r.y = ~v1.y; + r.z = ~v1.z; } }; } diff --git a/Engine/Source/Runtime/Core/public/Math/Detail/IntVector4Decl.inl b/Engine/Source/Runtime/Core/public/Math/Detail/IntVector4Decl.inl index c75481d..46aad0f 100644 --- a/Engine/Source/Runtime/Core/public/Math/Detail/IntVector4Decl.inl +++ b/Engine/Source/Runtime/Core/public/Math/Detail/IntVector4Decl.inl @@ -89,6 +89,14 @@ namespace Phanes::Core::Math::Detail v1.z = comp[2]; v1.w = comp[3]; } + + static constexpr void map(Phanes::Core::Math::TIntVector4& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + { + r.x = v1.x; + r.y = v1.y; + r.x = v2.x; + r.y = v2.y; + } }; diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector2.hpp b/Engine/Source/Runtime/Core/public/Math/IntVector2.hpp index 5758fa9..07d8472 100644 --- a/Engine/Source/Runtime/Core/public/Math/IntVector2.hpp +++ b/Engine/Source/Runtime/Core/public/Math/IntVector2.hpp @@ -362,12 +362,10 @@ namespace Phanes::Core::Math { */ template - FORCEINLINE TIntVector2 operator% (const TIntVector2& v1, const TIntVector2& v2); + inline TIntVector2 operator% (const TIntVector2& v1, const TIntVector2& v2); template - FORCEINLINE TIntVector2 operator% (const TIntVector2& v1, T s); - - + inline TIntVector2 operator% (const TIntVector2& v1, T s); template inline TIntVector2 operator& (TIntVector2& v1, const TIntVector2& v2); @@ -430,10 +428,13 @@ namespace Phanes::Core::Math { template bool operator!= (const TIntVector2& v1, const TIntVector2& v2); + + // ============================================== // // TIntVector2 static function implementation // // ============================================== // + template TIntVector2 MaxV(TIntVector2& v1, const TIntVector2& v2) { @@ -470,24 +471,6 @@ namespace Phanes::Core::Math { return v1; } - /** - * Component wise multiplication of Vector - * - * @param(v1) Vector one - * @param(v2) Vector two - * - * @note Stores new Vector to v1 - */ - - template - TIntVector2 ScaleV(TIntVector2& v1, const TIntVector2& v2) - { - v1.x *= v2.x; - v1.y *= v2.y; - - return v1; - } - /** * Copies one Vector two another * @@ -581,7 +564,7 @@ namespace Phanes::Core::Math { template inline bool IsCoincident(const TIntVector2& v1, const TIntVector2& v2) { - return (DotP(v1, v2) > 1); + return (DotP(v1, v2) = 1); } /** diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector3.hpp b/Engine/Source/Runtime/Core/public/Math/IntVector3.hpp index d1c601b..d56696f 100644 --- a/Engine/Source/Runtime/Core/public/Math/IntVector3.hpp +++ b/Engine/Source/Runtime/Core/public/Math/IntVector3.hpp @@ -47,10 +47,7 @@ namespace Phanes::Core::Math { * Copy constructor */ - TIntVector3(const TIntVector3& v) - { - memcpy(this->comp, comp, sizeof(T) * 3); - } + TIntVector3(const TIntVector3& v); /** * Construct Vector from xyz components. @@ -60,7 +57,13 @@ namespace Phanes::Core::Math { * @param(z) Z component */ - TIntVector3(const T x, const T y, const T z) : x(x), y(y), z(z) {}; + TIntVector3(const T x, const T y, const T z); + + /// + /// Broadcast s into all components. + /// + /// + TIntVector3(const T s); /** * Construct Vector from two component array. @@ -68,24 +71,9 @@ namespace Phanes::Core::Math { * @param(comp) Array of components */ - TIntVector3(const T* comp) - { - memcpy(this->comp, comp, sizeof(T) * 3); - } - - /** - * Constructs a vector pointing from start to end. - * - * @param(start) Startingpoint - * @param(end) Endpoint - */ - - TIntVector3(const TIntPoint3& start, const TIntPoint3& end) - { - this->x = end.x - start.x; - this->y = end.y - start.y; - this->z = end.z - start.z; - } + TIntVector3(const T* comp); + + TIntVector3(const TIntVector2& v1, const T s) }; @@ -102,15 +90,8 @@ namespace Phanes::Core::Math { * @param(s) scalar to add */ - template - inline TIntVector3 operator+= (TIntVector3& v1, T s) - { - v1.x += s; - v1.y += s; - v1.z += s; - - return v1; - } + template + inline TIntVector3 operator+= (TIntVector3& v1, T s); /** * Coponentwise addition of 3D vector to 3D vector @@ -119,15 +100,8 @@ namespace Phanes::Core::Math { * @param(v2) vector to add */ - template - inline TIntVector3 operator+= (TIntVector3& v1, const TIntVector3& v2) - { - v1.x += v2.x; - v1.y += v2.y; - v1.z += v2.z; - - return v1; - } + template + inline TIntVector3 operator+= (TIntVector3& v1, const TIntVector3& v2); /** * Coponentwise substraction of scalar of 3D vector @@ -136,15 +110,8 @@ namespace Phanes::Core::Math { * @param(s) scalar to substract */ - template - inline TIntVector3 operator-= (TIntVector3& v1, T s) - { - v1.x -= s; - v1.y -= s; - v1.z -= s; - - return v1; - } + template + inline TIntVector3 operator-= (TIntVector3& v1, T s); /** * Coponentwise substraction of 3D vector to 3D vector @@ -153,15 +120,8 @@ namespace Phanes::Core::Math { * @param(v2) vector to substract with */ - template - inline TIntVector3 operator-= (TIntVector3& v1, const TIntVector3& v2) - { - v1.x -= v2.x; - v1.y -= v2.y; - v1.z -= v2.z; - - return v1; - } + template + inline TIntVector3 operator-= (TIntVector3& v1, const TIntVector3& v2); /** * Dot product between two 3D Vectors @@ -170,15 +130,8 @@ namespace Phanes::Core::Math { * @param(s) scalar */ - template - inline TIntVector3 operator*= (TIntVector3& v1, T s) - { - v1.x *= s; - v1.y *= s; - v1.z *= s; - - return v1; - } + template + inline TIntVector3 operator*= (TIntVector3& v1, T s); /** * Division of vector by scalar @@ -187,34 +140,45 @@ namespace Phanes::Core::Math { * @param(s) scalar */ - template - inline TIntVector3 operator/= (TIntVector3& v1, T s) - { - float _1_s = 1.0f / s; + template + inline TIntVector3 operator/= (TIntVector3& v1, T s); - v1.x *= s; - v1.y *= s; - v1.z *= s; - return v1; - } + template + TIntVector2 operator%= (TIntVector2& v1, const TIntVector2& v2); - /** - * Stores remainder of division with scalar - * - * @param(v1) vector one - * @param(s) scalar - */ + template + TIntVector2 operator%= (TIntVector2& v1, T s); - template - inline TIntVector3 operator%= (TIntVector3& v1, T s) - { - v1.x %= s; - v1.y %= s; - v1.z %= s; + template + inline TIntVector2 operator&= (TIntVector2& v1, const TIntVector2& v2); - return v1; - } + template + inline TIntVector2 operator&= (TIntVector2& v1, T s); + + template + inline TIntVector2 operator|= (TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator|= (TIntVector2& v1, T s); + + template + inline TIntVector2 operator^= (TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator^= (TIntVector2& v1, T s); + + template + inline TIntVector2 operator<<= (TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator<<= (TIntVector2& v1, T s); + + template + inline TIntVector2 operator>>= (TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator>>= (TIntVector2& v1, T s); /** * Coponentwise multiplication of 3D Vectors with scalar @@ -225,11 +189,8 @@ namespace Phanes::Core::Math { * @return Resulting vector */ - template - TIntVector3 operator* (const TIntVector3& v1, T s) - { - return TIntVector3(v1.x * s, v1.y * s, v1.z * s); - } + template + TIntVector3 operator* (const TIntVector3& v1, T s); /** * Coponentwise multiplication of 3D Vectors with scalar @@ -240,11 +201,8 @@ namespace Phanes::Core::Math { * @return Solution vector */ - template - FORCEINLINE TIntVector3 operator* (T s, const TIntVector3& v1) - { - return v1 * s; - } + template + FORCEINLINE TIntVector3 operator* (T s, const TIntVector3& v1) { return v1 / s; }; /** * Division by scalar @@ -255,33 +213,51 @@ namespace Phanes::Core::Math { * @return Solution vector */ - template - inline TIntVector3 operator/ (const TIntVector3& v1, T s) - { - float _1_s = 1.0f / s; - return TIntVector3(v1.x * s, v1.y * s, v1.z * s); - } + template + inline TIntVector3 operator/ (const TIntVector3& v1, T s); - template - FORCEINLINE TIntVector3 operator/ (T s, const TIntVector3& v1) - { - return v1 / s; - } + template + FORCEINLINE TIntVector3 operator/ (T s, const TIntVector3& v1) { return v1 / s; }; - /** - * Stores remainder of division by scalar - * - * @param(s) scalar - * @param(v2) vector - * - * @return Solution vector - */ - template - inline TIntVector3 operator% (T s, const TIntVector3& v1) - { - return TIntVector3(v1.x % s, v1.y % s, v1.z % s); - } + template + inline TIntVector2 operator% (const TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator% (const TIntVector2& v1, T s); + + template + inline TIntVector2 operator& (TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator& (TIntVector2& v1, T s); + + template + inline TIntVector2 operator| (TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator| (TIntVector2& v1, T s); + + template + inline TIntVector2 operator^ (TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator^ (TIntVector2& v1, T s); + + template + inline TIntVector2 operator<< (TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator<< (TIntVector2& v1, T s); + + template + inline TIntVector2 operator>> (TIntVector2& v1, const TIntVector2& v2); + + template + inline TIntVector2 operator>> (TIntVector2& v1, T s); + + template + inline TIntVector2 operator~ (TIntVector2& v1); /** * Dot product between two 3D Vectors @@ -292,11 +268,8 @@ namespace Phanes::Core::Math { * @return Dot product of Vectors */ - template - T operator* (const TIntVector3& v1, const TIntVector3& v2) - { - return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; - } + template + TIntVector3 operator* (const TIntVector3& v1, const TIntVector3& v2); /** * Coponentwise addition of scalar to 3D vector @@ -307,11 +280,8 @@ namespace Phanes::Core::Math { * @return Resulting vector */ - template - TIntVector3 operator+ (const TIntVector3& v1, T s) - { - return TIntVector3(v1.x + s.v1.y + s, v1.z + s); - } + template + TIntVector3 operator+ (const TIntVector3& v1, T s); /** * Coponentwise addition of 3D vector to 3D vector @@ -322,11 +292,8 @@ namespace Phanes::Core::Math { * @return Resulting vector */ - template - TIntVector3 operator+ (const TIntVector3& v1, const TIntVector3& v2) - { - return TIntVector3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); - } + template + TIntVector3 operator+ (const TIntVector3& v1, const TIntVector3& v2); /** * Coponentwise substraction of scalar of 3D vector @@ -337,11 +304,8 @@ namespace Phanes::Core::Math { * @return Resulting vector */ - template - TIntVector3 operator- (const TIntVector3& v1, T s) - { - return TIntVector3(v1.x - s.v1.y - s, v1.z - s); - } + template + TIntVector3 operator- (const TIntVector3& v1, T s); /** * Coponentwise substraction of scalar of 3D vector @@ -352,27 +316,8 @@ namespace Phanes::Core::Math { * @return Resulting vector */ - template - TIntVector3 operator- (const TIntVector3& v1, const TIntVector3& v2) - { - return TIntVector3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); - } - - /** - * Negates vector - * - * @param(v1) Vector to negate - */ - - template - TIntVector3 operator- (TIntVector3& v1) - { - v1.x = -v1.x; - v1.y = -v1.y; - v1.z = -v1.z; - - return v1; - } + template + TIntVector3 operator- (const TIntVector3& v1, const TIntVector3& v2); /** * Tests two 3D vectors for equality. @@ -387,11 +332,8 @@ namespace Phanes::Core::Math { * @note Uses [MACRO]P_FLT_INAC */ - template - inline bool operator== (const TIntVector3& v1, const TIntVector3& v2) - { - return (abs(v1.x - v2.x) < P_FLT_INAC && abs(v1.y - v2.y) < P_FLT_INAC && abs(v1.z - v2.z) < P_FLT_INAC); - } + template + inline bool operator== (const TIntVector3& v1, const TIntVector3& v2); /** * Tests two 3D vectors for inequality. @@ -402,11 +344,8 @@ namespace Phanes::Core::Math { * @return True if inequal, false if not. */ - template - inline bool operator!= (const TIntVector3& v1, const TIntVector3& v2) - { - return (abs(v1.x - v2.x) > P_FLT_INAC || abs(v1.y - v2.y) > P_FLT_INAC || abs(v1.z - v2.z) > P_FLT_INAC); - } + template + inline bool operator!= (const TIntVector3& v1, const TIntVector3& v2); // ============================================== // @@ -423,7 +362,7 @@ namespace Phanes::Core::Math { */ template - T DotP(const TIntVector3& v1, const TIntVector3& v2) + T DotP(const TIntVector3& v1, const TIntVector3& v2) { return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; } @@ -439,7 +378,7 @@ namespace Phanes::Core::Math { */ template - inline bool Equals(const TIntVector3& v1, const TIntVector3& v2, T threshold = P_FLT_INAC) + inline bool Equals(const TIntVector3& v1, const TIntVector3& v2, T threshold = P_FLT_INAC) { return (abs(v1.x - v2.x) < threshold && abs(v1.y - v2.y) < threshold && abs(v1.z - v2.z) < threshold); } @@ -454,7 +393,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 CrossPV(TIntVector3& v1, const TIntVector3& v2) + TIntVector3 CrossPV(TIntVector3& v1, const TIntVector3& v2) { float x = v1.x; float y = v1.y; @@ -477,7 +416,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 MaxV(TIntVector3& v1, const TIntVector3& v2) + TIntVector3 MaxV(TIntVector3& v1, const TIntVector3& v2) { v1.x = Phanes::Core::Math::Max(v1.x, v2.x); v1.y = Phanes::Core::Math::Max(v1.y, v2.y); @@ -496,7 +435,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 MinV(TIntVector3& v1, const TIntVector3& v2) + TIntVector3 MinV(TIntVector3& v1, const TIntVector3& v2) { v1.x = Phanes::Core::Math::Min(v1.x, v2.x); v1.y = Phanes::Core::Math::Min(v1.y, v2.y); @@ -514,7 +453,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 NegateV(TIntVector3& v1) + TIntVector3 NegateV(TIntVector3& v1) { v1.x = -v1.x; v1.y = -v1.y; @@ -533,7 +472,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 ScaleV(TIntVector3& v1, const TIntVector3& v2) + TIntVector3 ScaleV(TIntVector3& v1, const TIntVector3& v2) { v1.x *= v2.x; v1.y *= v2.y; @@ -550,7 +489,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 Set(TIntVector3& v1, const TIntVector3& v2) + TIntVector3 Set(TIntVector3& v1, const TIntVector3& v2) { v1 = v2; @@ -567,7 +506,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 Set(TIntVector3& v1, T x, T y, T z) + TIntVector3 Set(TIntVector3& v1, T x, T y, T z) { v1.x = x; v1.y = y; @@ -583,7 +522,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 SignVectorV(TIntVector3& v1) + TIntVector3 SignVectorV(TIntVector3& v1) { v1.x = (v1.x >= 0) ? 1 : -1; v1.y = (v1.y >= 0) ? 1 : -1; @@ -604,7 +543,7 @@ namespace Phanes::Core::Math { */ template - T ScalarTriple(const TIntVector3& v1, const TIntVector3& v2, const TIntVector3& v3) + T ScalarTriple(const TIntVector3& v1, const TIntVector3& v2, const TIntVector3& v3) { return CrossP(v1, v2) * v3; } @@ -620,7 +559,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 VectorTripleV(TIntVector3& v1, const TIntVector3& v2, const TIntVector3& v3) + TIntVector3 VectorTripleV(TIntVector3& v1, const TIntVector3& v2, const TIntVector3& v3) { CrossPV(CrossPV(v1, v2), v3); @@ -637,7 +576,7 @@ namespace Phanes::Core::Math { */ template - inline bool IsPerpendicular(const TIntVector3& v1, const TIntVector3& v2) + inline bool IsPerpendicular(const TIntVector3& v1, const TIntVector3& v2) { return (DotP(v1, v2) == 0); } @@ -652,7 +591,7 @@ namespace Phanes::Core::Math { */ template - inline bool IsParallel(const TIntVector3& v1, const TIntVector3& v2) + inline bool IsParallel(const TIntVector3& v1, const TIntVector3& v2) { return (abs(DotP(v1, v2)) == 1); } @@ -667,7 +606,7 @@ namespace Phanes::Core::Math { */ template - inline bool IsCoincident(const TIntVector3& v1, const TIntVector3& v2) + inline bool IsCoincident(const TIntVector3& v1, const TIntVector3& v2) { return (DotP(v1, v2) == 1); } @@ -683,7 +622,7 @@ namespace Phanes::Core::Math { */ template - inline bool IsCoplanar(const TIntVector3& v1, const TIntVector3& v2, const TIntVector3& v3) + inline bool IsCoplanar(const TIntVector3& v1, const TIntVector3& v2, const TIntVector3& v3) { return (ScalarTriple(v1, v2, v3) == 0); } @@ -703,9 +642,9 @@ namespace Phanes::Core::Math { */ template - TIntVector3 CrossP(const TIntVector3& v1, const TIntVector3& v2) + TIntVector3 CrossP(const TIntVector3& v1, const TIntVector3& v2) { - return TIntVector3((v1.y * v2.z) - (v1.z * v2.y), + return TIntVector3((v1.y * v2.z) - (v1.z * v2.y), (v1.z * v2.x) - (v1.x * v2.z), (v1.x * v2.y) - (v1.y * v2.x)); } @@ -720,9 +659,9 @@ namespace Phanes::Core::Math { */ template - TIntVector3 Max(const TIntVector3& v1, const TIntVector3& v2) + TIntVector3 Max(const TIntVector3& v1, const TIntVector3& v2) { - return TIntVector3((v1.x > v2.x) ? v1.x : v2.x, + return TIntVector3((v1.x > v2.x) ? v1.x : v2.x, (v1.y > v2.y) ? v1.y : v2.y, (v1.z > v2.z) ? v1.z : v2.z); } @@ -737,9 +676,9 @@ namespace Phanes::Core::Math { */ template - TIntVector3 Min(const TIntVector3& v1, const TIntVector3& v2) + TIntVector3 Min(const TIntVector3& v1, const TIntVector3& v2) { - return TIntVector3((v1.x < v2.x) ? v1.x : v2.x, + return TIntVector3((v1.x < v2.x) ? v1.x : v2.x, (v1.y < v2.y) ? v1.y : v2.y, (v1.z < v2.z) ? v1.z : v2.z); } @@ -753,9 +692,9 @@ namespace Phanes::Core::Math { */ template - TIntVector3 Negate(const TIntVector3& v1) + TIntVector3 Negate(const TIntVector3& v1) { - return TIntVector3(-v1.x, -v1.y, -v1.z); + return TIntVector3(-v1.x, -v1.y, -v1.z); } /** @@ -768,9 +707,9 @@ namespace Phanes::Core::Math { */ template - TIntVector3 Scale(const TIntVector3& v1, const TIntVector3& v2) + TIntVector3 Scale(const TIntVector3& v1, const TIntVector3& v2) { - return TIntVector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); + return TIntVector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); } /** @@ -784,7 +723,7 @@ namespace Phanes::Core::Math { */ template - TIntVector3 VectorTriple(const TIntVector3& v1, const TIntVector3& v2, const TIntVector3& v3) + TIntVector3 VectorTriple(const TIntVector3& v1, const TIntVector3& v2, const TIntVector3& v3) { return CrossP(CrossP(v1, v2), v3); } diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector3.inl b/Engine/Source/Runtime/Core/public/Math/IntVector3.inl new file mode 100644 index 0000000..fcc7093 --- /dev/null +++ b/Engine/Source/Runtime/Core/public/Math/IntVector3.inl @@ -0,0 +1,409 @@ +#pragma once + +#include "Core/public/Math/Boilerplate.h" + +#include "Core/public/Math/Detail/IntVector3Decl.inl" +#include "Core/public/Math/SIMD/SIMDIntrinsics.h" + +#include "Core/public/Math/SIMD/PhanesSIMDTypes.h" + +#include "IntVector3.hpp" + +namespace Phanes::Core::Math +{ + template + TIntVector3::TIntVector3(const TIntVector3& v) + { + Detail::construct_ivec3::value>::map(*this, v); + } + + template + TIntVector3::TIntVector3(const T _x, const T _y, const T _z) + { + Detail::construct_ivec3::value>::map(*this, _x, _y, _z, _w); + } + + template + TIntVector3::TIntVector3(const T s) + { + Detail::construct_ivec3::value>::map(*this, s); + } + + template + TIntVector3::TIntVector3(const T* comp) + { + Detail::construct_ivec3::value>::map(*this, comp); + } + + template + TIntVector3::TIntVector3(const TIntVector2& v1, const T s) + { + Detail::construct_ivec3::value>::map(*this, v1, s); + } + + + + + template + TIntVector3 operator+=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_add::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator+=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_add::value>::map(v1, v1, s); + return v1; + } + + template + TIntVector3 operator-=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_sub::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator-=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_sub::value>::map(v1, v1, s); + return v1; + } + + template + TIntVector3 operator*=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_mul::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator*=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_mul::value>::map(v1, v1, s); + return v1; + } + + template + TIntVector3 operator/=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_div::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator/=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_div::value>::map(v1, v1, s); + return v1; + } + + template + TIntVector3 operator%=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_mod::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator%=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_mod::value>::map(v1, v1, s); + return v1; + } + + + template + TIntVector3 operator+(TIntVector3& v1, const TIntVector3& v2) + { + TIntVector3 r; + Detail::compute_ivec3_add::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator+(TIntVector3& v1, T s) + { + TIntVector3 r; + Detail::compute_ivec3_add::value>::map(r, v1, s); + return r; + } + + template + TIntVector3 operator-(TIntVector3& v1, const TIntVector3& v2) + { + TIntVector3 r; + Detail::compute_ivec3_sub::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator-(TIntVector3& v1, T s) + { + TIntVector3 r; + Detail::compute_ivec3_sub::value>::map(r, v1, s); + return r; + } + + template + TIntVector3 operator*(TIntVector3& v1, const TIntVector3& v2) + { + TIntVector3 r; + Detail::compute_ivec3_mul::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator*(TIntVector3& v1, T s) + { + TIntVector3 r; + Detail::compute_ivec3_mul::value>::map(r, v1, s); + return r; + } + + template + TIntVector3 operator/(TIntVector3& v1, const TIntVector3& v2) + { + TIntVector3 r; + Detail::compute_ivec3_div::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator/(TIntVector3& v1, T s) + { + TIntVector3 r; + Detail::compute_ivec3_div::value>::map(r, v1, s); + return r; + } + + template + TIntVector3 operator%(TIntVector3& v1, const TIntVector3& v2) + { + TIntVector3 r; + Detail::compute_ivec3_mod::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator%(TIntVector3& v1, T s) + { + TIntVector3 r; + Detail::compute_ivec3_mod::value>::map(r, v1, s); + return r; + } + + + + + // Bitwise operators + + template + TIntVector3 operator&=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_and::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator&=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_and::value>::map(v1, v1, s); + return v1; + } + + template + TIntVector3 operator|=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_or::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator|=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_or::value>::map(v1, v1, s); + return v1; + } + + template + TIntVector3 operator^=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_xor::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator^=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_xor::value>::map(v1, v1, s); + return v1; + } + + template + TIntVector3 operator<<=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_left_shift::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator<<=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_left_shift::value>::map(v1, v1, s); + return v1; + } + + template + TIntVector3 operator>>=(TIntVector3& v1, const TIntVector3& v2) + { + Detail::compute_ivec3_right_shift::value>::map(v1, v1, v2); + return v1; + } + + template + TIntVector3 operator>>=(TIntVector3& v1, T s) + { + Detail::compute_ivec3_right_shift::value>::map(v1, v1, s); + return v1; + } + + + + template + TIntVector3 operator&(TIntVector3& v1, const TIntVector3& v2) + { + TVector2 r; + Detail::compute_ivec3_and::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator&(TIntVector3& v1, T s) + { + TVector2 r; + Detail::compute_ivec3_and::value>::map(r, v1, s); + return r; + } + + template + TIntVector3 operator|(TIntVector3& v1, const TIntVector3& v2) + { + TVector2 r; + Detail::compute_ivec3_or::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator|(TIntVector3& v1, T s) + { + TVector2 r; + Detail::compute_ivec3_or::value>::map(r, v1, s); + return r; + } + + template + TIntVector3 operator^(TIntVector3& v1, const TIntVector3& v2) + { + TVector2 r; + Detail::compute_ivec3_xor::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator^(TIntVector3& v1, T s) + { + TVector2 r; + Detail::compute_ivec3_xor::value>::map(r, v1, s); + return r; + } + + template + TIntVector3 operator<<(TIntVector3& v1, const TIntVector3& v2) + { + TVector2 r; + Detail::compute_ivec3_left_shift::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator<<(TIntVector3& v1, T s) + { + TVector2 r; + Detail::compute_ivec3_left_shift::value>::map(r, v1, s); + return r; + } + + template + TIntVector3 operator>>(TIntVector3& v1, const TIntVector3& v2) + { + TVector2 r; + Detail::compute_ivec3_right_shift::value>::map(r, v1, v2); + return r; + } + + template + TIntVector3 operator>>(TIntVector3& v1, T s) + { + TVector2 r; + Detail::compute_ivec3_right_shift::value>::map(r, v1, s); + return r; + } + + template + TIntVector3 operator~(TIntVector3& v1) + { + TVector2 r; + Detail::compute_ivec3_bnot::value>::map(r, v1); + return r; + } + + + + // Comparision + + template + bool operator==(const TIntVector3& v1, const TIntVector3& v2) + { + return Detail::compute_ivec3_eq::value>::map(v1, v2); + } + + template + bool operator!=(const TIntVector3& v1, const TIntVector3& v2) + { + return Detail::compute_ivec3_ieq::value>::map(v1, v2); + } + + + + // Inc- / Decrement + + + template + TIntVector3& operator++(TIntVector3& v1) + { + Detail::compute_ivec3_inc::value>::map(v1); + return v1; + } + + template + TIntVector3& operator--(TIntVector3& v1) + { + Detail::compute_ivec3_inc::value>::map(v1); + return v1; + } + + template + TIntVector3& operator++(TIntVector3& v1, int) + { + return ++v1; + } + + template + TIntVector3& operator--(TIntVector3& v1, int) + { + return --v1; + } +} \ No newline at end of file diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector4.hpp b/Engine/Source/Runtime/Core/public/Math/IntVector4.hpp index ff3d6c4..60e74d3 100644 --- a/Engine/Source/Runtime/Core/public/Math/IntVector4.hpp +++ b/Engine/Source/Runtime/Core/public/Math/IntVector4.hpp @@ -435,8 +435,226 @@ namespace Phanes::Core::Math { + + // ========================= // + // TIntVector4 functions // + // ========================= // + + template + void Set(TIntVector4& v1, TIntVector4& v2) + { + v1.x = v2.x; + v1.y = v2.y; + v1.z = v2.z; + v1.w = v2.w; + } + + + /// + /// Calculates the dot product between two vectors. + /// + /// Type of vector + /// Vector is aligned? + /// Vector one + /// Vector two + /// Dot product between vectors. + template + T DotP(const TIntVector4& v1, const TIntVector4& v2) + { + return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w; + } + + /// + /// Gets componentwise max of both vectors. + /// + /// Type of vector + /// Vector is aligned? + /// Vector one + /// Vector two + /// Vector with componentwise max of both vectors. + template + TIntVector4 Max(const TIntVector4& v1, const TIntVector4& v2) + { + return TIntVector4( + (v1.x > v2.x) ? v1.x : v2.x, + (v1.y > v2.y) ? v1.y : v2.y, + (v1.z > v2.z) ? v1.z : v2.z, + (v1.w > v2.w) ? v1.w : v2.w + ); + } + + /// + /// Gets componentwise max of both vectors. + /// + /// Type of vector + /// Vector is aligned? + /// Vector one + /// Vector two + /// Copy of v1. + template + TIntVector4 MaxV(TIntVector4& v1, const TIntVector4& v2) + { + v1.x = (v1.x > v2.x) ? v1.x : v2.x; + v1.y = (v1.y > v2.y) ? v1.y : v2.y; + v1.z = (v1.z > v2.z) ? v1.z : v2.z; + v1.w = (v1.w > v2.w) ? v1.w : v2.w; + + return v1; + } + + /// + /// Gets componentwise min of both vectors. + /// + /// Type of vector + /// Vector is aligned? + /// Vector one + /// Vector two + /// Vector with componentwise max of both vectors. + template + TIntVector4 Min(const TIntVector4& v1, const TIntVector4& v2) + { + return TIntVector4( + (v1.x < v2.x) ? v1.x : v2.x, + (v1.y < v2.y) ? v1.y : v2.y, + (v1.z < v2.z) ? v1.z : v2.z, + (v1.w < v2.w) ? v1.w : v2.w + ); + } + + /// + /// Gets componentwise min of both vectors. + /// + /// Type of vector + /// Vector is aligned? + /// Vector one + /// Vector two + /// Copy of v1. + template + TIntVector4 MinV(TIntVector4& v1, const TIntVector4& v2) + { + v1.x = (v1.x < v2.x) ? v1.x : v2.x; + v1.y = (v1.y < v2.y) ? v1.y : v2.y; + v1.z = (v1.z < v2.z) ? v1.z : v2.z; + v1.w = (v1.w < v2.w) ? v1.w : v2.w; + + return v1; + } + + /// + /// Inverses vector. + /// + /// Type of vector + /// Vector is aligned? + /// Vector + /// Inverted vector + template + TIntVector4 Negate(const TIntVector4& v1) + { + return TIntVector4( + -v1.x, + -v1.y, + -v1.z, + -v1.w + ); + } + + /// + /// Inverses vector. + /// + /// Type of vector + /// Vector is aligned? + /// Vector + /// Copy of v1. + template + TIntVector4 NegateV(TIntVector4& v1) + { + v1.x = -v1.x; + v1.y = -v1.y; + v1.z = -v1.z; + v1.w = -v1.w; + } + + /// + /// Get signs of components. + /// + /// + -> +1 + /// + /// x -> -1 + /// + /// Type of vector + /// Vector is aligned? + /// Vector with signs of components. + template + TIntVector4 SignVector(TIntVector4& v1) + { + return TIntVector4( + (v1.x > 0) ? 1 : -1, + (v1.y > 0) ? 1 : -1, + (v1.z > 0) ? 1 : -1, + (v1.w > 0) ? 1 : -1, + ); + } + + /// + /// Get signs of components. + /// + /// + -> +1 + /// + /// x -> -1 + /// + /// Type of vector + /// + template + TIntVector4 SignVectorV(TIntVector4& v1) + { + v1.x = (v1.x > 0) ? 1 : -1; + v1.y = (v1.y > 0) ? 1 : -1; + v1.z = (v1.z > 0) ? 1 : -1; + v1.w = (v1.w > 0) ? 1 : -1; + } + + /// + /// Test if two vectors are perpendicular. + /// + /// Type of vector + /// + /// + /// True if perpendicular. + template + inline bool IsPerpendicular(const TIntVector4& v1, const TIntVector4& v2) + { + return (abs(DotP(v1, v2)) = 0); + } + + /// + /// Test if two vectors are parallel. + /// + /// Type of vector + /// + /// + /// True if parralel. + template + inline bool IsParallel(const TIntVector4& v1, const TIntVector4& v2) + { + return (abs(DotP(v1, v2)) = 1); + } + + /// + /// Test if two vectors are parallel. + /// + /// + /// + /// + /// + template + inline bool IsCoincident(const TIntVector4& v1, const TIntVector4& v2) + { + return (DotP(v1, v2) = 1); + } + } // phanes::core::math::coretypes + #endif // !INTVECTOR3_H diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector4.inl b/Engine/Source/Runtime/Core/public/Math/IntVector4.inl index 251f5e0..e92c105 100644 --- a/Engine/Source/Runtime/Core/public/Math/IntVector4.inl +++ b/Engine/Source/Runtime/Core/public/Math/IntVector4.inl @@ -7,8 +7,6 @@ #include "Core/public/Math/SIMD/PhanesSIMDTypes.h" -#include "IntVector4.hpp" - namespace Phanes::Core::Math { template diff --git a/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathFPU.hpp b/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathFPU.hpp index 94f7c74..c2794ea 100644 --- a/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathFPU.hpp +++ b/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathFPU.hpp @@ -137,6 +137,7 @@ namespace Phanes::Core::Math::Detail v1.w = s[3]; } + }; diff --git a/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathSSE.hpp b/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathSSE.hpp index 94d6add..31ea41f 100644 --- a/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathSSE.hpp +++ b/Engine/Source/Runtime/Core/public/Math/SIMD/PhanesVectorMathSSE.hpp @@ -524,6 +524,11 @@ namespace Phanes::Core::Math::Detail { v1.comp = _mm_loadu_epi32(comp); } + + static FORCEINLINE void map(Phanes::Core::Math::TIntVector4& r, const Phanes::Core::Math::TIntVector2& v1, const Phanes::Core::Math::TIntVector2& v2) + { + r.comp = _mm_setr_epi32(v1.x, v1.y, v2.x, v2.y); + } }; template<>