diff --git a/src/Math/include/litefx/math.hpp b/src/Math/include/litefx/math.hpp index 8bb3cbda..b1de742e 100644 --- a/src/Math/include/litefx/math.hpp +++ b/src/Math/include/litefx/math.hpp @@ -30,48 +30,128 @@ namespace LiteFX::Math { using namespace LiteFX; + /// + /// A type for an unsigned 8 bit integer. + /// using Byte = uint8_t; + + /// + /// A type for a signed 16 bit integer. + /// using Int16 = int16_t; + + /// + /// A type for an unsigned 16 bit integer. + /// using UInt16 = uint16_t; + + /// + /// A type for a signed 32 bit integer. + /// using Int32 = int32_t; + + /// + /// A type for an unsigned 32 bit integer. + /// using UInt32 = uint32_t; + + /// + /// A type for a signed 64 bit integer. + /// using Int64 = int64_t; + + /// + /// A type for an unsigned 64 bit integer. + /// using UInt64 = uint64_t; + + /// + /// A type for a floating point value with single precision. + /// using Float = float_t; + + /// + /// A type for a floating point value with double precision. + /// using Double = double_t; + /// + /// A literal to define a byte. + /// + /// The value that should be assigned to the byte. + /// The value as byte. inline constexpr Byte operator "" _b(unsigned long long int arg) noexcept { return static_cast(arg); } + /// + /// A literal to define a 16 bit integer. + /// + /// The value that should be assigned to the integer. + /// The value as 16 bit integer. inline constexpr Int16 operator "" _i16(unsigned long long int arg) noexcept { return static_cast(arg); } + /// + /// A literal to define a 16 bit unsigned integer. + /// + /// The value that should be assigned to the integer. + /// The value as 16 bit unsigned integer. inline constexpr UInt16 operator "" _ui16(unsigned long long int arg) noexcept { return static_cast(arg); } + /// + /// A literal to define a 32 bit integer. + /// + /// The value that should be assigned to the integer. + /// The value as 32 bit integer. inline constexpr Int32 operator "" _i32(unsigned long long int arg) noexcept { return static_cast(arg); } + /// + /// A literal to define a 32 bit unsigned integer. + /// + /// The value that should be assigned to the integer. + /// The value as 32 bit unsigned integer. inline constexpr UInt32 operator "" _ui32(unsigned long long int arg) noexcept { return static_cast(arg); } + /// + /// A literal to define a 64 bit integer. + /// + /// The value that should be assigned to the integer. + /// The value as 64 bit integer. inline constexpr Int64 operator "" _i64(unsigned long long int arg) noexcept { return static_cast(arg); } + /// + /// A literal to define a 64 bit unsigned integer. + /// + /// The value that should be assigned to the integer. + /// The value as 64 bit unsigned integer. inline constexpr UInt64 operator "" _ui64(unsigned long long int arg) noexcept { return static_cast(arg); } + /// + /// A literal to define a floating point value with single precision. + /// + /// The value that should be assigned to the floating point number. + /// The value as floating point number. inline constexpr Float operator "" _f32(long double arg) noexcept { return static_cast(arg); } + /// + /// A literal to define a floating point value with double precision. + /// + /// The value that should be assigned to the floating point number. + /// The value as floating point number. inline constexpr Double operator "" _f64(long double arg) noexcept { return static_cast(arg); } @@ -89,214 +169,305 @@ namespace LiteFX::Math { } #pragma region Vector + /// + /// A vector that contains a single float. + /// class LITEFX_MATH_API Vector1f : public Vector { public: - Vector1f() noexcept; - Vector1f(Float v) noexcept; - Vector1f(const Vector1f&) noexcept; - Vector1f(const Vector&) noexcept; - Vector1f(Vector1f&&) noexcept; - Vector1f(Vector&&) noexcept; - //virtual ~Vector1f() noexcept = default; - - public: - inline Vector1f& operator=(const Vector& _other) noexcept; - inline Vector1f& operator=(Vector&& _other) noexcept; - inline Vector1f& operator=(const Enumerable& _other) noexcept; - inline Vector1f& operator=(const Vector1f& _other) noexcept; - inline Vector1f& operator=(Vector1f&& _other) noexcept; - inline Float operator[](UInt32 i) const noexcept; - inline Float& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: + /// + /// Converts a vector of type `glm::f32vec1`. + /// + /// The vector to convert. Vector1f(const glm::f32vec1& v) noexcept; + + /// + /// Converts a vector of type `glm::f32vec1`. + /// + /// The vector to convert. Vector1f(glm::f32vec1&& v) noexcept; + + /// + /// Converts the vector into the type `glm::f32vec1`. + /// inline operator glm::f32vec1() const noexcept; #endif #if defined(LITEFX_BUILD_WITH_DIRECTX_MATH) public: + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector1f(const DirectX::XMVECTOR& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector1f(DirectX::XMVECTOR&& v) noexcept; + + /// + /// Converts the vector into the type `DirectX::XMVECTOR`. + /// inline operator DirectX::XMVECTOR() const noexcept; #endif }; + // NOTE: Vector1i unsupported, due to lack of `XMStoreSInt` overload for scalar signed integers. + + /// + /// A vector that contains a single unsigned integer. + /// class LITEFX_MATH_API Vector1u : public Vector { public: - Vector1u() noexcept; - Vector1u(UInt32 v) noexcept; - Vector1u(const Vector1u&) noexcept; - Vector1u(const Vector&) noexcept; - Vector1u(Vector1u&&) noexcept; - Vector1u(Vector&&) noexcept; - //virtual ~Vector1u() noexcept = default; - inline operator UInt32() noexcept; - - public: - inline Vector1u& operator=(const Vector& _other) noexcept; - inline Vector1u& operator=(Vector&& _other) noexcept; - inline Vector1u& operator=(const Enumerable& _other) noexcept; - inline Vector1u& operator=(const Vector1u& _other) noexcept; - inline Vector1u& operator=(Vector1u&& _other) noexcept; - inline UInt32 operator[](UInt32 i) const noexcept; - inline UInt32& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: + /// + /// Converts a vector of type `glm::u32vec1`. + /// + /// The vector to convert. Vector1u(const glm::u32vec1& v) noexcept; + + /// + /// Converts a vector of type `glm::u32vec1`. + /// + /// The vector to convert. Vector1u(glm::u32vec1&& v) noexcept; + + /// + /// Converts the vector into the type `glm::u32vec1`. + /// inline operator glm::u32vec1() const noexcept; #endif #if defined(LITEFX_BUILD_WITH_DIRECTX_MATH) public: + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector1u(const DirectX::XMVECTOR& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector1u(DirectX::XMVECTOR&& v) noexcept; + + /// + /// Converts the vector into the type `DirectX::XMVECTOR`. + /// inline operator DirectX::XMVECTOR() const noexcept; #endif }; + /// + /// A vector that contains two floats. + /// class LITEFX_MATH_API Vector2f : public Vector { public: - Vector2f() noexcept; - Vector2f(Float v) noexcept; - Vector2f(Float x, Float y) noexcept; - Vector2f(const Vector2f&) noexcept; - Vector2f(const Vector&) noexcept; - Vector2f(Vector2f&&) noexcept; - Vector2f(Vector&&) noexcept; - //virtual ~Vector2f() noexcept = default; - - public: - inline Vector2f& operator=(const Vector& _other) noexcept; - inline Vector2f& operator=(Vector&& _other) noexcept; - inline Vector2f& operator=(const Enumerable& _other) noexcept; - inline Vector2f& operator=(const Vector2f& _other) noexcept; - inline Vector2f& operator=(Vector2f&& _other) noexcept; - inline Float operator[](UInt32 i) const noexcept; - inline Float& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: + /// + /// Converts a vector of type `glm::f32vec2`. + /// + /// The vector to convert. Vector2f(const glm::f32vec2& v) noexcept; + + /// + /// Converts a vector of type `glm::f32vec2`. + /// + /// The vector to convert. Vector2f(glm::f32vec2&& v) noexcept; + + /// + /// Converts the vector into the type `glm::f32vec2`. + /// inline operator glm::f32vec2() const noexcept; #endif #if defined(LITEFX_BUILD_WITH_DIRECTX_MATH) public: + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector2f(const DirectX::XMVECTOR& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector2f(DirectX::XMVECTOR&& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMFLOAT2`. + /// + /// The vector to convert. Vector2f(const DirectX::XMFLOAT2& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMFLOAT2`. + /// + /// The vector to convert. Vector2f(DirectX::XMFLOAT2&& v) noexcept; + + /// + /// Converts the vector into the type `DirectX::XMVECTOR`. + /// inline operator DirectX::XMVECTOR() const noexcept; + + /// + /// Converts the vector into the type `DirectX::XMFLOAT2`. + /// inline operator DirectX::XMFLOAT2() const noexcept; #endif }; + /// + /// A vector that contains two unsigned integers. + /// class LITEFX_MATH_API Vector2u : public Vector { public: - Vector2u() noexcept; - Vector2u(UInt32 v) noexcept; - Vector2u(UInt32 x, UInt32 y) noexcept; - Vector2u(const Vector2u&) noexcept; - Vector2u(const Vector&) noexcept; - Vector2u(Vector2u&&) noexcept; - Vector2u(Vector&&) noexcept; - //virtual ~Vector2u() noexcept = default; - - public: - inline Vector2u& operator=(const Vector& _other) noexcept; - inline Vector2u& operator=(Vector&& _other) noexcept; - inline Vector2u& operator=(const Enumerable& _other) noexcept; - inline Vector2u& operator=(const Vector2u& _other) noexcept; - inline Vector2u& operator=(Vector2u&& _other) noexcept; - inline UInt32 operator[](UInt32 i) const noexcept; - inline UInt32& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: + /// + /// Converts a vector of type `glm::u32vec2`. + /// + /// The vector to convert. Vector2u(const glm::u32vec2& v) noexcept; + + /// + /// Converts a vector of type `glm::u32vec2`. + /// + /// The vector to convert. Vector2u(glm::u32vec2&& v) noexcept; + + /// + /// Converts the vector into the type `glm::u32vec2`. + /// inline operator glm::u32vec2() const noexcept; #endif #if defined(LITEFX_BUILD_WITH_DIRECTX_MATH) public: + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector2u(const DirectX::XMVECTOR& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector2u(DirectX::XMVECTOR&& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMUINT2`. + /// + /// The vector to convert. Vector2u(const DirectX::XMUINT2& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMUINT2`. + /// + /// The vector to convert. Vector2u(DirectX::XMUINT2&& v) noexcept; + + /// + /// Converts the vector into the type `DirectX::XMVECTOR`. + /// inline operator DirectX::XMVECTOR() const noexcept; + + /// + /// Converts the vector into the type `DirectX::XMUINT2`. + /// inline operator DirectX::XMUINT2() const noexcept; #endif }; + /// + /// A vector that contains two signed integers. + /// class LITEFX_MATH_API Vector2i : public Vector { public: - Vector2i() noexcept; - Vector2i(Int32 v) noexcept; - Vector2i(Int32 x, Int32 y) noexcept; - Vector2i(const Vector2i&) noexcept; - Vector2i(const Vector&) noexcept; - Vector2i(Vector2i&&) noexcept; - Vector2i(Vector&&) noexcept; - //virtual ~Vector2i() noexcept = default; - - public: - inline Vector2i& operator=(const Vector& _other) noexcept; - inline Vector2i& operator=(Vector&& _other) noexcept; - inline Vector2i& operator=(const Enumerable& _other) noexcept; - inline Vector2i& operator=(const Vector2i& _other) noexcept; - inline Vector2i& operator=(Vector2i&& _other) noexcept; - inline Int32 operator[](UInt32 i) const noexcept; - inline Int32& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: + /// + /// Converts a vector of type `glm::i32vec2`. + /// + /// The vector to convert. Vector2i(const glm::i32vec2& v) noexcept; + + /// + /// Converts a vector of type `glm::i32vec2`. + /// + /// The vector to convert. Vector2i(glm::i32vec2&& v) noexcept; + + /// + /// Converts the vector into the type `glm::i32vec2`. + /// inline operator glm::i32vec2() const noexcept; #endif #if defined(LITEFX_BUILD_WITH_DIRECTX_MATH) public: + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector2i(const DirectX::XMVECTOR& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMVECTOR`. + /// + /// The vector to convert. Vector2i(DirectX::XMVECTOR&& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMINT2`. + /// + /// The vector to convert. Vector2i(const DirectX::XMINT2& v) noexcept; + + /// + /// Converts a vector of type `DirectX::XMINT2`. + /// + /// The vector to convert. Vector2i(DirectX::XMINT2&& v) noexcept; + + /// + /// Converts the vector into the type `DirectX::XMVECTOR`. + /// inline operator DirectX::XMVECTOR() const noexcept; + + /// + /// Converts the vector into the type `DirectX::XMINT2`. + /// inline operator DirectX::XMINT2() const noexcept; #endif }; + /// + /// A vector that stores three floats. + /// class LITEFX_MATH_API Vector3f : public Vector { public: - Vector3f() noexcept; - Vector3f(Float v) noexcept; - Vector3f(Float x, Float y, Float z) noexcept; - Vector3f(const Vector3f&) noexcept; - Vector3f(const Vector&) noexcept; - Vector3f(Vector3f&&) noexcept; - Vector3f(Vector&&) noexcept; - //virtual ~Vector3f() noexcept = default; - - public: - inline Vector3f& operator=(const Vector& _other) noexcept; - inline Vector3f& operator=(Vector&& _other) noexcept; - inline Vector3f& operator=(const Enumerable& _other) noexcept; - inline Vector3f& operator=(const Vector3f& _other) noexcept; - inline Vector3f& operator=(Vector3f&& _other) noexcept; - inline Float operator[](UInt32 i) const noexcept; - inline Float& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: @@ -318,24 +489,7 @@ namespace LiteFX::Math { class LITEFX_MATH_API Vector3u : public Vector { public: - Vector3u() noexcept; - Vector3u(UInt32 v) noexcept; - Vector3u(UInt32 x, UInt32 y, UInt32 z) noexcept; - Vector3u(const Vector3u&) noexcept; - Vector3u(const Vector&) noexcept; - Vector3u(Vector3u&&) noexcept; - Vector3u(Vector&&) noexcept; - //virtual ~Vector3u() noexcept = default; - - public: - inline Vector3u& operator=(const Vector& _other) noexcept; - inline Vector3u& operator=(Vector&& _other) noexcept; - inline Vector3u& operator=(const Enumerable& _other) noexcept; - inline Vector3u& operator=(const Vector3u& _other) noexcept; - inline Vector3u& operator=(Vector3u&& _other) noexcept; - inline UInt32 operator[](UInt32 i) const noexcept; - inline UInt32& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: @@ -357,24 +511,7 @@ namespace LiteFX::Math { class LITEFX_MATH_API Vector3i : public Vector { public: - Vector3i() noexcept; - Vector3i(Int32 v) noexcept; - Vector3i(Int32 x, Int32 y, Int32 z) noexcept; - Vector3i(const Vector3i&) noexcept; - Vector3i(const Vector&) noexcept; - Vector3i(Vector3i&&) noexcept; - Vector3i(Vector&&) noexcept; - //virtual ~Vector3i() noexcept = default; - - public: - inline Vector3i& operator=(const Vector& _other) noexcept; - inline Vector3i& operator=(Vector&& _other) noexcept; - inline Vector3i& operator=(const Enumerable& _other) noexcept; - inline Vector3i& operator=(const Vector3i& _other) noexcept; - inline Vector3i& operator=(Vector3i&& _other) noexcept; - inline Int32 operator[](UInt32 i) const noexcept; - inline Int32& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: @@ -396,24 +533,7 @@ namespace LiteFX::Math { class LITEFX_MATH_API Vector4f : public Vector { public: - Vector4f() noexcept; - Vector4f(Float v) noexcept; - Vector4f(Float x, Float y, Float z, Float w) noexcept; - Vector4f(const Vector4f&) noexcept; - Vector4f(const Vector&) noexcept; - Vector4f(Vector4f&&) noexcept; - Vector4f(Vector&&) noexcept; - //virtual ~Vector4f() noexcept = default; - - public: - inline Vector4f& operator=(const Vector& _other) noexcept; - inline Vector4f& operator=(Vector&& _other) noexcept; - inline Vector4f& operator=(const Enumerable& _other) noexcept; - inline Vector4f& operator=(const Vector4f& _other) noexcept; - inline Vector4f& operator=(Vector4f&& _other) noexcept; - inline Float operator[](UInt32 i) const noexcept; - inline Float& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: @@ -435,24 +555,7 @@ namespace LiteFX::Math { class LITEFX_MATH_API Vector4u : public Vector { public: - Vector4u() noexcept; - Vector4u(UInt32 v) noexcept; - Vector4u(UInt32 x, UInt32 y, UInt32 z, UInt32 w) noexcept; - Vector4u(const Vector4u&) noexcept; - Vector4u(const Vector&) noexcept; - Vector4u(Vector4u&&) noexcept; - Vector4u(Vector&&) noexcept; - //virtual ~Vector4u() noexcept = default; - - public: - inline Vector4u& operator=(const Vector& _other) noexcept; - inline Vector4u& operator=(Vector&& _other) noexcept; - inline Vector4u& operator=(const Enumerable& _other) noexcept; - inline Vector4u& operator=(const Vector4u& _other) noexcept; - inline Vector4u& operator=(Vector4u&& _other) noexcept; - inline UInt32 operator[](UInt32 i) const noexcept; - inline UInt32& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: @@ -474,24 +577,7 @@ namespace LiteFX::Math { class LITEFX_MATH_API Vector4i : public Vector { public: - Vector4i() noexcept; - Vector4i(Int32 v) noexcept; - Vector4i(Int32 x, Int32 y, Int32 z, Int32 w) noexcept; - Vector4i(const Vector4i&) noexcept; - Vector4i(const Vector&) noexcept; - Vector4i(Vector4i&&) noexcept; - Vector4i(Vector&&) noexcept; - //virtual ~Vector4i() noexcept = default; - - public: - inline Vector4i& operator=(const Vector& _other) noexcept; - inline Vector4i& operator=(Vector&& _other) noexcept; - inline Vector4i& operator=(const Enumerable& _other) noexcept; - inline Vector4i& operator=(const Vector4i& _other) noexcept; - inline Vector4i& operator=(Vector4i&& _other) noexcept; - inline Int32 operator[](UInt32 i) const noexcept; - inline Int32& operator[](UInt32 i) noexcept; - inline operator Enumerable() noexcept; + using Vector::Vector; #if defined(LITEFX_BUILD_WITH_GLM) public: @@ -511,43 +597,188 @@ namespace LiteFX::Math { #endif }; - // Define exported vector types. + /// + /// Contains additional exported vector types. + /// namespace Vectors { + /// + /// A vector that contains a single byte. + /// using ByteVector1 = TVector1; + + /// + /// A vector that contains two bytes. + /// using ByteVector2 = TVector2; + + /// + /// A vector that contains three bytes. + /// using ByteVector3 = TVector3; + + /// + /// A vector that contains four bytes. + /// using ByteVector4 = TVector4; + + /// + /// A vector that contains a single 16 bit signed integer. + /// using Int16Vector1 = TVector1; + + /// + /// A vector that contains two 16 bit signed integers. + /// using Int16Vector2 = TVector2; + + /// + /// A vector that contains three 16 bit signed integers. + /// using Int16Vector3 = TVector3; + + /// + /// A vector that contains four 16 bit signed integers. + /// using Int16Vector4 = TVector4; + + /// + /// A vector that contains a single 16 bit unsigned integer. + /// using UInt16Vector1 = TVector1; + + /// + /// A vector that contains two 16 bit unsigned integers. + /// using UInt16Vector2 = TVector2; + + /// + /// A vector that contains three 16 bit unsigned integers. + /// using UInt16Vector3 = TVector3; + + /// + /// A vector that contains four 16 bit unsigned integers. + /// using UInt16Vector4 = TVector4; + + /// + /// A vector that contains a single 32 bit signed integer. + /// using Int32Vector1 = TVector1; + + /// + /// A vector that contains two 32 bit signed integers. + /// using Int32Vector2 = TVector2; + + /// + /// A vector that contains three 32 bit signed integers. + /// using Int32Vector3 = TVector3; + + /// + /// A vector that contains four 32 bit signed integers. + /// using Int32Vector4 = TVector4; + + /// + /// A vector that contains a single 32 bit unsigned integer. + /// using UInt32Vector1 = TVector1; + + /// + /// A vector that contains two 32 bit unsigned integers. + /// using UInt32Vector2 = TVector2; + + /// + /// A vector that contains three 32 bit unsigned integers. + /// using UInt32Vector3 = TVector3; + + /// + /// A vector that contains four 32 bit unsigned integers. + /// using UInt32Vector4 = TVector4; + + /// + /// A vector that contains a single 64 bit signed integer. + /// using Int64Vector1 = TVector1; + + /// + /// A vector that contains two 64 bit signed integers. + /// using Int64Vector2 = TVector2; + + /// + /// A vector that contains three 64 bit signed integers. + /// using Int64Vector3 = TVector3; + + /// + /// A vector that contains four 64 bit signed integers. + /// using Int64Vector4 = TVector4; + + /// + /// A vector that contains a single 64 bit unsigned integer. + /// using UInt64Vector1 = TVector1; + + /// + /// A vector that contains two 64 bit unsigned integers. + /// using UInt64Vector2 = TVector2; + + /// + /// A vector that contains three 64 bit unsigned integers. + /// using UInt64Vector3 = TVector3; + + /// + /// A vector that contains four 64 bit unsigned integers. + /// using UInt64Vector4 = TVector4; + + /// + /// A vector that contains a single floating point value with single precision. + /// using FloatVector1 = TVector1; + + /// + /// A vector that contains two floating point values with single precision. + /// using FloatVector2 = TVector2; + + /// + /// A vector that contains three floating point values with single precision. + /// using FloatVector3 = TVector3; + + /// + /// A vector that contains four floating point values with single precision. + /// using FloatVector4 = TVector4; + + /// + /// A vector that contains a single floating point value with double precision. + /// using DoubleVector1 = TVector1; + + /// + /// A vector that contains two floating point values with double precision. + /// using DoubleVector2 = TVector2; + + /// + /// A vector that contains three floating point values with double precision. + /// using DoubleVector3 = TVector3; + + /// + /// A vector that contains four floating point values with double precision. + /// using DoubleVector4 = TVector4; } #pragma endregion diff --git a/src/Math/include/litefx/vector.hpp b/src/Math/include/litefx/vector.hpp index c8477cfe..8ea19e94 100644 --- a/src/Math/include/litefx/vector.hpp +++ b/src/Math/include/litefx/vector.hpp @@ -2,125 +2,328 @@ #include #include +#include +#include +#include namespace LiteFX::Math { - template - class Vector { - public: - static constexpr size_t vec_size = DIM; - using scalar_type = T; - using vec_type = Vector; - - protected: - using array_type = std::array; - array_type m_elements = { }; - - public: - Vector() noexcept = default; - - Vector(T val) noexcept { - std::fill(std::begin(m_elements), std::end(m_elements), val); - } - - inline Vector(const vec_type& _other) noexcept { operator=(_other); } - inline Vector(vec_type&& _other) noexcept { operator=(_other); } - //virtual inline ~Vector() noexcept = default; - - Vector(T x, T y) noexcept requires(DIM == 2) { - m_elements[0] = x; - m_elements[1] = y; - }; - - Vector(T x, T y, T z) noexcept requires(DIM == 3) { - m_elements[0] = x; - m_elements[1] = y; - m_elements[2] = z; - }; - - Vector(T x, T y, T z, T w) noexcept requires(DIM == 4) { - m_elements[0] = x; - m_elements[1] = y; - m_elements[2] = z; - m_elements[3] = w; - }; - - public: - Vector& operator= (const Vector& _other) noexcept { - std::ranges::copy(_other.m_elements, std::begin(m_elements)); - return *this; - } - - Vector& operator= (Vector&& _other) noexcept { - std::ranges::move(_other.m_elements, std::begin(m_elements)); - return *this; - } - - inline T operator[](unsigned int i) const noexcept { - assert(i < DIM); - - return m_elements[i]; - } - - inline T& operator[](unsigned int i) noexcept { - assert(i < DIM); - - return m_elements[i]; - } - - inline auto begin() const noexcept { - return m_elements.begin(); - } - - inline auto end() const noexcept { - return m_elements.end(); - } - - public: - inline const scalar_type* elements() const noexcept { - return m_elements.data(); - } - - inline int size() const noexcept { - return vec_size; - } - - inline scalar_type x() const noexcept requires (DIM > 0) { - return m_elements[0]; - } - - inline scalar_type& x() noexcept requires (DIM > 0) { - return m_elements[0]; - } - - inline scalar_type y() const noexcept requires (DIM > 1) { - return m_elements[1]; - } - - inline scalar_type& y() noexcept requires (DIM > 1) { - return m_elements[1]; - } - - inline scalar_type z() const noexcept requires (DIM > 2) { - return m_elements[2]; - } - - inline scalar_type& z() noexcept requires (DIM > 2) { - return m_elements[2]; - } - - inline scalar_type w() const noexcept requires (DIM > 3) { - return m_elements[3]; - } - - inline scalar_type& w() noexcept requires (DIM > 3) { - return m_elements[3]; - } - }; + /// + /// Base class for a algebraic vector type. + /// + /// The type of the vector scalar elements. + /// The number of dimensions of the vector. + template + class Vector { + public: + /// + /// Stores the size of the vector. + /// + static constexpr size_t vec_size = DIM; + /// + /// The type of the vector elements. + /// + using scalar_type = T; + + /// + /// The type of the vector itself. + /// + using vec_type = Vector; + + protected: + using array_type = std::array; + array_type m_elements = { }; + + public: + /// + /// Initializes an empty vector. + /// + constexpr inline Vector() noexcept = default; + + /// + /// Initializes a vector where all elements take the value provided by . + /// + /// The value to initialize all elements of the vector with. + constexpr inline Vector(T val) noexcept { + std::fill(std::begin(m_elements), std::end(m_elements), val); + } + + /// + /// Initializes a vector with the values provided by another vector. + /// + /// The other vector to copy the values from. + constexpr inline Vector(const vec_type& _other) noexcept { + std::ranges::copy(_other.m_elements, std::begin(m_elements)); + } + + /// + /// Initializes a vector by taking over another vector. + /// + /// The vector to take over. + constexpr inline Vector(vec_type&& _other) noexcept { + m_elements = std::move(_other.m_elements); + } + + //virtual inline ~Vector() noexcept = default; + + /// + /// Initializes a 2D vector using the values provided by and . + /// + /// The value to initialize the x-component of the vector with. + /// The value to initialize the y-component of the vector with. + constexpr inline Vector(T x, T y) noexcept requires(DIM == 2) { + m_elements[0] = x; + m_elements[1] = y; + }; + + /// + /// Initializes a 3D vector using the values provided by , and . + /// + /// The value to initialize the x-component of the vector with. + /// The value to initialize the y-component of the vector with. + /// The value to initialize the z-component of the vector with. + constexpr inline Vector(T x, T y, T z) noexcept requires(DIM == 3) { + m_elements[0] = x; + m_elements[1] = y; + m_elements[2] = z; + }; + + /// + /// Initializes a 4D vector using the values provided by , , and . + /// + /// The value to initialize the x-component of the vector with. + /// The value to initialize the y-component of the vector with. + /// The value to initialize the z-component of the vector with. + /// The value to initialize the w-component of the vector with. + constexpr inline Vector(T x, T y, T z, T w) noexcept requires(DIM == 4) { + m_elements[0] = x; + m_elements[1] = y; + m_elements[2] = z; + m_elements[3] = w; + }; + + /// + /// Initializes the vector from an arbitrary input range. + /// + /// The range to initialize the vector with. + constexpr inline explicit Vector(std::ranges::input_range auto&& input) noexcept requires + std::is_nothrow_convertible_v, T> + { + std::ranges::copy(input, std::begin(m_elements)); + } + + /// + /// Copys the elements of another vector into the current vector. + /// + /// The vector to copy the elements from. + /// A reference to the current vector instance. + constexpr inline auto& operator=(const vec_type& _other) noexcept { + std::ranges::copy(_other.m_elements, std::begin(m_elements)); + return *this; + } + + /// + /// Moves the elements of the other vector to the current vector. + /// + /// The vector to take over. + /// A reference to the current vector instance. + constexpr inline auto& operator=(vec_type&& _other) noexcept { + m_elements = std::move(_other.m_elements); + return *this; + } + + /// + /// Copies the values from an arbitrary input range into the current vector instance. + /// + /// The input range to copy the values from. + /// A reference to the current vector instance. + constexpr inline auto& operator=(std::ranges::input_range auto&& input) noexcept requires + std::is_nothrow_convertible_v, T> + { + std::ranges::copy(input, std::begin(m_elements)); + return *this; + } + + public: + /// + /// Returns a value from the vector, indexed by the parameter . + /// + /// + /// Note that this method wraps the index if it is out of range, i.e., calling the method with index `4` on a 4D vector will return the element at index `0`. + /// + /// The index of the element to return. + /// The value of the element at the provided index. + constexpr inline T operator[](unsigned int i) const noexcept { + assert(i < DIM); + + return m_elements[i % DIM]; + } + + /// + /// Returns a reference to a value from the vector, indexed by the parameter . + /// + /// + /// Note that this method wraps the index if it is out of range, i.e., calling the method with index `4` on a 4D vector will return the element at index `0`. + /// + /// The index of the element to return. + /// A reference to a value of the element at the provided index. + constexpr inline T& operator[](unsigned int i) noexcept { + assert(i < DIM); + + return m_elements[i % DIM]; + } + + /// + /// Returns an interator for that addresses the begin of the vector elements. + /// + /// An interator for that addresses the begin of the vector elements. + constexpr inline auto begin() noexcept { + return m_elements.begin(); + } + + /// + /// Returns an interator for that addresses the end of the vector elements. + /// + /// An interator for that addresses the end of the vector elements. + constexpr inline auto end() noexcept { + return m_elements.end(); + } + + /// + /// Returns a constant interator for that addresses the begin of the vector elements. + /// + /// A constant interator for that addresses the begin of the vector elements. + constexpr inline auto cbegin() const noexcept { + return m_elements.cbegin(); + } + + /// + /// Returns a constant interator for that addresses the end of the vector elements. + /// + /// A constant interator for that addresses the end of the vector elements. + constexpr inline auto cend() const noexcept { + return m_elements.cend(); + } + + public: + /// + /// Returns a pointer to the elements of the vector. + /// + /// A pointer to the elements of the vector. + constexpr inline const scalar_type* elements() const noexcept { + return m_elements.data(); + } + + /// + /// Converts the vector to an instance of `std::array`. + /// + constexpr inline operator std::array() const noexcept { + return m_elements; + } + + /// + /// Converts the vector into an instance of type `std::vector`. + /// + constexpr inline operator std::vector() const noexcept { + return std::vector(std::begin(m_elements), std::end(m_elements)); + } + + /// + /// Returns the number of dimensions of the vector. + /// + /// The number of dimensions of the vector. + constexpr inline int size() const noexcept { + return vec_size; + } + + /// + /// Returns the value of the x component of the vector. + /// + /// The value of the x component of the vector. + constexpr inline scalar_type x() const noexcept requires (DIM > 0) { + return m_elements[0]; + } + + /// + /// Returns a reference of the value of the x component of the vector. + /// + /// The a reference of the value of the x component of the vector. + constexpr inline scalar_type& x() noexcept requires (DIM > 0) { + return m_elements[0]; + } + + /// + /// Returns the value of the y component of the vector. + /// + /// The value of the y component of the vector. + constexpr inline scalar_type y() const noexcept requires (DIM > 1) { + return m_elements[1]; + } + + /// + /// Returns a reference of the value of the y component of the vector. + /// + /// The a reference of the value of the y component of the vector. + constexpr inline scalar_type& y() noexcept requires (DIM > 1) { + return m_elements[1]; + } + + /// + /// Returns the value of the z component of the vector. + /// + /// The value of the z component of the vector. + constexpr inline scalar_type z() const noexcept requires (DIM > 2) { + return m_elements[2]; + } + + /// + /// Returns a reference of the value of the z component of the vector. + /// + /// The a reference of the value of the z component of the vector. + constexpr inline scalar_type& z() noexcept requires (DIM > 2) { + return m_elements[2]; + } + + /// + /// Returns the value of the w component of the vector. + /// + /// The value of the w component of the vector. + constexpr inline scalar_type w() const noexcept requires (DIM > 3) { + return m_elements[3]; + } + + /// + /// Returns a reference of the value of the w component of the vector. + /// + /// The a reference of the value of the w component of the vector. + constexpr inline scalar_type& w() noexcept requires (DIM > 3) { + return m_elements[3]; + } + }; + + /// + /// A generic vector with one component. + /// + /// The type of the vector component. template using TVector1 = Vector; + + /// + /// A generic vector with two components. + /// + /// The type of the vector components. template using TVector2 = Vector; + + /// + /// A generic vector with three components. + /// + /// The type of the vector components. template using TVector3 = Vector; + + /// + /// A generic vector with four components. + /// + /// The type of the vector components. template using TVector4 = Vector; } \ No newline at end of file diff --git a/src/Math/src/vector.cpp b/src/Math/src/vector.cpp index 70af4ac5..6799d22b 100644 --- a/src/Math/src/vector.cpp +++ b/src/Math/src/vector.cpp @@ -6,48 +6,6 @@ using namespace LiteFX::Math; // Vector1f. // ------------------------------------------------------------------------------------------------ -Vector1f::Vector1f() noexcept : Vector() { } -Vector1f::Vector1f(Float v) noexcept : Vector(v) { } -Vector1f::Vector1f(const Vector1f& _v) noexcept : Vector(_v) { } -Vector1f::Vector1f(const Vector& _v) noexcept : Vector(_v) { } -Vector1f::Vector1f(Vector1f&& _v) noexcept : Vector(_v) { } -Vector1f::Vector1f(Vector&& _v) noexcept : Vector(_v) { } - -Vector1f& Vector1f::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector1f& Vector1f::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector1f& Vector1f::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector1f& Vector1f::operator=(const Vector1f& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector1f& Vector1f::operator=(Vector1f&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -Float Vector1f::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -Float& Vector1f::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector1f::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector1f::Vector1f(const glm::f32vec1& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -80,51 +38,6 @@ Vector1f::operator DirectX::XMVECTOR() const noexcept { // Vector1u. // ------------------------------------------------------------------------------------------------ -Vector1u::Vector1u() noexcept : Vector() { } -Vector1u::Vector1u(UInt32 v) noexcept : Vector(v) { } -Vector1u::Vector1u(const Vector1u& _v) noexcept : Vector(_v) { } -Vector1u::Vector1u(const Vector& _v) noexcept : Vector(_v) { } -Vector1u::Vector1u(Vector1u&& _v) noexcept : Vector(_v) { } -Vector1u::Vector1u(Vector&& _v) noexcept : Vector(_v) { } - -Vector1u& Vector1u::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector1u& Vector1u::operator=(Vector&& _other) noexcept { - std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { - return std::move(_other[i++]); - }); - - return *this; -} - -Vector1u& Vector1u::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector1u& Vector1u::operator=(const Vector1u& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector1u& Vector1u::operator=(Vector1u&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -UInt32 Vector1u::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -UInt32& Vector1u::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector1u::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector1u::Vector1u(const glm::u32vec1& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -157,53 +70,6 @@ Vector1u::operator DirectX::XMVECTOR() const noexcept { // Vector2f. // ------------------------------------------------------------------------------------------------ -Vector2f::Vector2f() noexcept : Vector() { } -Vector2f::Vector2f(Float v) noexcept : Vector(v) { } -Vector2f::Vector2f(Float x, Float y) noexcept : Vector() { - this->x() = x; - this->y() = y; -} - -Vector2f::Vector2f(const Vector2f& _v) noexcept : Vector(_v) { } -Vector2f::Vector2f(const Vector& _v) noexcept : Vector(_v) { } -Vector2f::Vector2f(Vector2f&& _v) noexcept : Vector(_v) { } -Vector2f::Vector2f(Vector&& _v) noexcept : Vector(_v) { } - -Vector2f& Vector2f::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector2f& Vector2f::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector2f& Vector2f::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector2f& Vector2f::operator=(const Vector2f& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector2f& Vector2f::operator=(Vector2f&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -Float Vector2f::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -Float& Vector2f::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector2f::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector2f::Vector2f(const glm::f32vec2& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -259,53 +125,6 @@ Vector2f::operator DirectX::XMFLOAT2() const noexcept { // Vector2u. // ------------------------------------------------------------------------------------------------ -Vector2u::Vector2u() noexcept : Vector() { } -Vector2u::Vector2u(UInt32 v) noexcept : Vector(v) { } -Vector2u::Vector2u(UInt32 x, UInt32 y) noexcept : Vector() { - this->x() = x; - this->y() = y; -} - -Vector2u::Vector2u(const Vector2u& _v) noexcept : Vector(_v) { } -Vector2u::Vector2u(const Vector& _v) noexcept : Vector(_v) { } -Vector2u::Vector2u(Vector2u&& _v) noexcept : Vector(_v) { } -Vector2u::Vector2u(Vector&& _v) noexcept : Vector(_v) { } - -Vector2u& Vector2u::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector2u& Vector2u::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector2u& Vector2u::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector2u& Vector2u::operator=(const Vector2u& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector2u& Vector2u::operator=(Vector2u&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -UInt32 Vector2u::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -UInt32& Vector2u::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector2u::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector2u::Vector2u(const glm::u32vec2& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -361,53 +180,6 @@ Vector2u::operator DirectX::XMUINT2() const noexcept { // Vector2i. // ------------------------------------------------------------------------------------------------ -Vector2i::Vector2i() noexcept : Vector() { } -Vector2i::Vector2i(Int32 v) noexcept : Vector(v) { } -Vector2i::Vector2i(Int32 x, Int32 y) noexcept : Vector() { - this->x() = x; - this->y() = y; -} - -Vector2i::Vector2i(const Vector2i& _v) noexcept : Vector(_v) { } -Vector2i::Vector2i(const Vector& _v) noexcept : Vector(_v) { } -Vector2i::Vector2i(Vector2i&& _v) noexcept : Vector(_v) { } -Vector2i::Vector2i(Vector&& _v) noexcept : Vector(_v) { } - -Vector2i& Vector2i::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector2i& Vector2i::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector2i& Vector2i::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector2i& Vector2i::operator=(const Vector2i& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector2i& Vector2i::operator=(Vector2i&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -Int32 Vector2i::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -Int32& Vector2i::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector2i::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector2i::Vector2i(const glm::i32vec2& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -463,54 +235,6 @@ Vector2i::operator DirectX::XMINT2() const noexcept { // Vector3f. // ------------------------------------------------------------------------------------------------ -Vector3f::Vector3f() noexcept : Vector() { } -Vector3f::Vector3f(Float v) noexcept : Vector(v) { } -Vector3f::Vector3f(Float x, Float y, Float z) noexcept : Vector() { - this->x() = x; - this->y() = y; - this->z() = z; -} - -Vector3f::Vector3f(const Vector3f& _v) noexcept : Vector(_v) { } -Vector3f::Vector3f(const Vector& _v) noexcept : Vector(_v) { } -Vector3f::Vector3f(Vector3f&& _v) noexcept : Vector(_v) { } -Vector3f::Vector3f(Vector&& _v) noexcept : Vector(_v) { } - -Vector3f& Vector3f::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector3f& Vector3f::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector3f& Vector3f::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector3f& Vector3f::operator=(const Vector3f& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector3f& Vector3f::operator=(Vector3f&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -Float Vector3f::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -Float& Vector3f::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector3f::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector3f::Vector3f(const glm::f32vec3& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -570,54 +294,6 @@ Vector3f::operator DirectX::XMFLOAT3() const noexcept { // Vector3u. // ------------------------------------------------------------------------------------------------ -Vector3u::Vector3u() noexcept : Vector() { } -Vector3u::Vector3u(UInt32 v) noexcept : Vector(v) { } -Vector3u::Vector3u(UInt32 x, UInt32 y, UInt32 z) noexcept : Vector() { - this->x() = x; - this->y() = y; - this->z() = z; -} - -Vector3u::Vector3u(const Vector3u& _v) noexcept : Vector(_v) { } -Vector3u::Vector3u(const Vector& _v) noexcept : Vector(_v) { } -Vector3u::Vector3u(Vector3u&& _v) noexcept : Vector(_v) { } -Vector3u::Vector3u(Vector&& _v) noexcept : Vector(_v) { } - -Vector3u& Vector3u::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector3u& Vector3u::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector3u& Vector3u::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector3u& Vector3u::operator=(const Vector3u& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector3u& Vector3u::operator=(Vector3u&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -UInt32 Vector3u::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -UInt32& Vector3u::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector3u::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector3u::Vector3u(const glm::u32vec3& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -677,54 +353,6 @@ Vector3u::operator DirectX::XMUINT3() const noexcept { // Vector3i. // ------------------------------------------------------------------------------------------------ -Vector3i::Vector3i() noexcept : Vector() { } -Vector3i::Vector3i(Int32 v) noexcept : Vector(v) { } -Vector3i::Vector3i(Int32 x, Int32 y, Int32 z) noexcept : Vector() { - this->x() = x; - this->y() = y; - this->z() = z; -} - -Vector3i::Vector3i(const Vector3i& _v) noexcept : Vector(_v) { } -Vector3i::Vector3i(const Vector& _v) noexcept : Vector(_v) { } -Vector3i::Vector3i(Vector3i&& _v) noexcept : Vector(_v) { } -Vector3i::Vector3i(Vector&& _v) noexcept : Vector(_v) { } - -Vector3i& Vector3i::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector3i& Vector3i::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector3i& Vector3i::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector3i& Vector3i::operator=(const Vector3i& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector3i& Vector3i::operator=(Vector3i&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -Int32 Vector3i::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -Int32& Vector3i::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector3i::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector3i::Vector3i(const glm::i32vec3& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -784,55 +412,6 @@ Vector3i::operator DirectX::XMINT3() const noexcept { // Vector4f. // ------------------------------------------------------------------------------------------------ -Vector4f::Vector4f() noexcept : Vector() { } -Vector4f::Vector4f(Float v) noexcept : Vector(v) { } -Vector4f::Vector4f(Float x, Float y, Float z, Float w) noexcept : Vector() { - this->x() = x; - this->y() = y; - this->z() = z; - this->w() = w; -} - -Vector4f::Vector4f(const Vector4f& _v) noexcept : Vector(_v) { } -Vector4f::Vector4f(const Vector& _v) noexcept : Vector(_v) { } -Vector4f::Vector4f(Vector4f&& _v) noexcept : Vector(_v) { } -Vector4f::Vector4f(Vector&& _v) noexcept : Vector(_v) { } - -Vector4f& Vector4f::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector4f& Vector4f::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector4f& Vector4f::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector4f& Vector4f::operator=(const Vector4f& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector4f& Vector4f::operator=(Vector4f&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -Float Vector4f::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -Float& Vector4f::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector4f::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector4f::Vector4f(const glm::f32vec4& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -896,55 +475,6 @@ Vector4f::operator DirectX::XMFLOAT4() const noexcept { // Vector4u. // ------------------------------------------------------------------------------------------------ -Vector4u::Vector4u() noexcept : Vector() { } -Vector4u::Vector4u(UInt32 v) noexcept : Vector(v) { } -Vector4u::Vector4u(UInt32 x, UInt32 y, UInt32 z, UInt32 w) noexcept : Vector() { - this->x() = x; - this->y() = y; - this->z() = z; - this->w() = w; -} - -Vector4u::Vector4u(const Vector4u& _v) noexcept : Vector(_v) { } -Vector4u::Vector4u(const Vector& _v) noexcept : Vector(_v) { } -Vector4u::Vector4u(Vector4u&& _v) noexcept : Vector(_v) { } -Vector4u::Vector4u(Vector&& _v) noexcept : Vector(_v) { } - -Vector4u& Vector4u::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector4u& Vector4u::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector4u& Vector4u::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector4u& Vector4u::operator=(const Vector4u& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector4u& Vector4u::operator=(Vector4u&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -UInt32 Vector4u::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -UInt32& Vector4u::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector4u::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector4u::Vector4u(const glm::u32vec4& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; }); @@ -1008,55 +538,6 @@ Vector4u::operator DirectX::XMUINT4() const noexcept { // Vector4i. // ------------------------------------------------------------------------------------------------ -Vector4i::Vector4i() noexcept : Vector() { } -Vector4i::Vector4i(Int32 v) noexcept : Vector(v) { } -Vector4i::Vector4i(Int32 x, Int32 y, Int32 z, Int32 w) noexcept : Vector() { - this->x() = x; - this->y() = y; - this->z() = z; - this->w() = w; -} - -Vector4i::Vector4i(const Vector4i& _v) noexcept : Vector(_v) { } -Vector4i::Vector4i(const Vector& _v) noexcept : Vector(_v) { } -Vector4i::Vector4i(Vector4i&& _v) noexcept : Vector(_v) { } -Vector4i::Vector4i(Vector&& _v) noexcept : Vector(_v) { } - -Vector4i& Vector4i::operator=(const Vector& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector4i& Vector4i::operator=(Vector&& _other) noexcept { - std::ranges::move(_other, std::begin(m_elements)); - return *this; -} - -Vector4i& Vector4i::operator=(const Enumerable& _other) noexcept { - std::ranges::copy(_other, std::begin(m_elements)); - return *this; -} - -Vector4i& Vector4i::operator=(const Vector4i& _other) noexcept { - return this->operator=(static_cast>(_other)); -} - -Vector4i& Vector4i::operator=(Vector4i&& _other) noexcept { - return this->operator=(std::move(static_cast>(_other))); -} - -Int32 Vector4i::operator[](UInt32 i) const noexcept { - return Vector::operator[](i); -} - -Int32& Vector4i::operator[](UInt32 i) noexcept { - return Vector::operator[](i); -} - -Vector4i::operator Enumerable() noexcept { - return m_elements; -} - #if defined(LITEFX_BUILD_WITH_GLM) Vector4i::Vector4i(const glm::i32vec4& v) noexcept { std::generate(std::begin(m_elements), std::end(m_elements), [&, i = 0]() mutable { return v[i++]; });