diff --git a/include/basis/seadTypes.h b/include/basis/seadTypes.h index bd1ec610..c9bceb85 100644 --- a/include/basis/seadTypes.h +++ b/include/basis/seadTypes.h @@ -24,6 +24,7 @@ using f64 = double; using char16 = char16_t; using size_t = std::size_t; +using uintptr = std::uintptr_t; #endif #endif // SEAD_NEW_H_ diff --git a/include/math/seadMatrix.h b/include/math/seadMatrix.h index fd5af108..f2b0c2a2 100644 --- a/include/math/seadMatrix.h +++ b/include/math/seadMatrix.h @@ -275,8 +275,10 @@ typedef Matrix22 Matrix22f; typedef Matrix33 Matrix33f; typedef Matrix34 Matrix34f; typedef Matrix44 Matrix44f; - -typedef Matrix34 Matrixf; +typedef Matrix22 Matrix22d; +typedef Matrix33 Matrix33d; +typedef Matrix34 Matrix34d; +typedef Matrix44 Matrix44d; template <> const Matrix22f Matrix22f::zero; @@ -303,28 +305,28 @@ template <> const Matrix44f Matrix44f::ident; template <> -const Matrix22 Matrix22::zero; +const Matrix22d Matrix22d::zero; template <> -const Matrix22 Matrix22::ident; +const Matrix22d Matrix22d::ident; template <> -const Matrix33 Matrix33::zero; +const Matrix33d Matrix33d::zero; template <> -const Matrix33 Matrix33::ident; +const Matrix33d Matrix33d::ident; template <> -const Matrix34 Matrix34::zero; +const Matrix34d Matrix34d::zero; template <> -const Matrix34 Matrix34::ident; +const Matrix34d Matrix34d::ident; template <> -const Matrix44 Matrix44::zero; +const Matrix44d Matrix44d::zero; template <> -const Matrix44 Matrix44::ident; +const Matrix44d Matrix44d::ident; template bool operator==(const Matrix34& lhs, const Matrix34& rhs); diff --git a/include/math/seadVector.h b/include/math/seadVector.h index 0d2e97be..4d0bf5eb 100644 --- a/include/math/seadVector.h +++ b/include/math/seadVector.h @@ -16,6 +16,10 @@ struct Vector2 : public Policies::Vec2Base Vector2() {} Vector2(const Vector2& other) = default; Vector2(T x, T y); + template + Vector2(const Vector2& other) : Vector2((T)other.x, (T)other.y) + { + } Vector2& operator=(const Vector2& other); @@ -88,6 +92,10 @@ struct Vector3 : public Policies::Vec3Base Vector3() {} Vector3(const Vector3& other) = default; Vector3(T x, T y, T z); + template + Vector3(const Vector3& other) : Vector3((T)other.x, (T)other.y, (T)other.z) + { + } Vector3& operator=(const Vector3& other); bool operator==(const Vector3& rhs) const; @@ -143,6 +151,7 @@ struct Vector3 : public Policies::Vec3Base friend Vector3 operator/(const Vector3& a, T t) { return {a.x / t, a.y / t, a.z / t}; } Vector3 operator-() const { return {-this->x, -this->y, -this->z}; } + Vector3 operator~() const { return {~this->x, ~this->y, ~this->z}; } Vector3 cross(const Vector3& t) const { @@ -204,6 +213,10 @@ struct Vector4 : public Policies::Vec4Base Vector4() {} Vector4(const Vector4& other) = default; Vector4(T x, T y, T z, T w); + template + Vector4(const Vector4& other) : Vector4((T)other.x, (T)other.y, (T)other.z, (T)other.w) + { + } Vector4& operator=(const Vector4& other); diff --git a/modules/src/math/seadMatrix.cpp b/modules/src/math/seadMatrix.cpp index d148a418..db61a565 100644 --- a/modules/src/math/seadMatrix.cpp +++ b/modules/src/math/seadMatrix.cpp @@ -3,55 +3,57 @@ namespace sead { template <> -const Matrix22 Matrix22::zero(0.0f, 0.0f, 0.0f, 0.0f); +const Matrix22f Matrix22f::zero(0.0f, 0.0f, 0.0f, 0.0f); template <> -const Matrix22 Matrix22::ident(1.0f, 0.0f, 0.0f, 1.0f); +const Matrix22f Matrix22f::ident(1.0f, 0.0f, 0.0f, 1.0f); template <> -const Matrix33 Matrix33::zero(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); +const Matrix33f Matrix33f::zero(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); template <> -const Matrix33 Matrix33::ident(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f); +const Matrix33f Matrix33f::ident(1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f); template <> -const Matrix34 Matrix34::zero(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f); +const Matrix34f Matrix34f::zero(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f); template <> -const Matrix34 Matrix34::ident(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 1.0f, 0.0f); +const Matrix34f Matrix34f::ident(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, + 0.0f); template <> -const Matrix44 Matrix44::zero(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); +const Matrix44f Matrix44f::zero(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); template <> -const Matrix44 Matrix44::ident(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); +const Matrix44f Matrix44f::ident(1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); template <> -const Matrix22 Matrix22::zero(0, 0, 0, 0); +const Matrix22d Matrix22d::zero(0.0, 0.0, 0.0, 0.0); template <> -const Matrix22 Matrix22::ident(1, 0, 0, 1); +const Matrix22d Matrix22d::ident(1.0, 0.0, 0.0, 1.0); template <> -const Matrix33 Matrix33::zero(0, 0, 0, 0, 0, 0, 0, 0, 0); +const Matrix33d Matrix33d::zero(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); template <> -const Matrix33 Matrix33::ident(1, 0, 0, 0, 1, 0, 0, 0, 1); +const Matrix33d Matrix33d::ident(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0); template <> -const Matrix34 Matrix34::zero(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +const Matrix34d Matrix34d::zero(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); template <> -const Matrix34 Matrix34::ident(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0); +const Matrix34d Matrix34d::ident(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); template <> -const Matrix44 Matrix44::zero(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +const Matrix44d Matrix44d::zero(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0); template <> -const Matrix44 Matrix44::ident(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1); +const Matrix44d Matrix44d::ident(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0); } // namespace sead diff --git a/modules/src/math/seadQuat.cpp b/modules/src/math/seadQuat.cpp index bdfa2f58..e1699875 100644 --- a/modules/src/math/seadQuat.cpp +++ b/modules/src/math/seadQuat.cpp @@ -3,5 +3,5 @@ namespace sead { template <> -const Quatf Quat::unit(1.0f, 0.0f, 0.0f, 0.0f); +const Quatf Quatf::unit(1.0f, 0.0f, 0.0f, 0.0f); } // namespace sead diff --git a/modules/src/math/seadVector.cpp b/modules/src/math/seadVector.cpp index 0773a710..1be8e94f 100644 --- a/modules/src/math/seadVector.cpp +++ b/modules/src/math/seadVector.cpp @@ -3,48 +3,138 @@ namespace sead { template <> -const Vector2 Vector2::zero(0.0f, 0.0f); +const Vector2f Vector2f::zero(0.0f, 0.0f); template <> -const Vector2 Vector2::ex(1.0f, 0.0f); +const Vector2f Vector2f::ex(1.0f, 0.0f); template <> -const Vector2 Vector2::ey(0.0f, 1.0f); +const Vector2f Vector2f::ey(0.0f, 1.0f); template <> -const Vector2 Vector2::ones(1.0f, 1.0f); +const Vector2f Vector2f::ones(1.0f, 1.0f); template <> -const Vector3 Vector3::zero(0.0f, 0.0f, 0.0f); +const Vector3f Vector3f::zero(0.0f, 0.0f, 0.0f); template <> -const Vector3 Vector3::ex(1.0f, 0.0f, 0.0f); +const Vector3f Vector3f::ex(1.0f, 0.0f, 0.0f); template <> -const Vector3 Vector3::ey(0.0f, 1.0f, 0.0f); +const Vector3f Vector3f::ey(0.0f, 1.0f, 0.0f); template <> -const Vector3 Vector3::ez(0.0f, 0.0f, 1.0f); +const Vector3f Vector3f::ez(0.0f, 0.0f, 1.0f); template <> -const Vector3 Vector3::ones(1.0f, 1.0f, 1.0f); +const Vector3f Vector3f::ones(1.0f, 1.0f, 1.0f); template <> -const Vector4 Vector4::zero(0.0f, 0.0f, 0.0f, 0.0f); +const Vector4f Vector4f::zero(0.0f, 0.0f, 0.0f, 0.0f); template <> -const Vector4 Vector4::ex(1.0f, 0.0f, 0.0f, 0.0f); +const Vector4f Vector4f::ex(1.0f, 0.0f, 0.0f, 0.0f); template <> -const Vector4 Vector4::ey(0.0f, 1.0f, 0.0f, 0.0f); +const Vector4f Vector4f::ey(0.0f, 1.0f, 0.0f, 0.0f); template <> -const Vector4 Vector4::ez(0.0f, 0.0f, 1.0f, 0.0f); +const Vector4f Vector4f::ez(0.0f, 0.0f, 1.0f, 0.0f); template <> -const Vector4 Vector4::ew(0.0f, 0.0f, 0.0f, 1.0f); +const Vector4f Vector4f::ew(0.0f, 0.0f, 0.0f, 1.0f); template <> -const Vector4 Vector4::ones(1.0f, 1.0f, 1.0f, 1.0f); +const Vector4f Vector4f::ones(1.0f, 1.0f, 1.0f, 1.0f); + +template <> +const Vector2i Vector2i::zero(0, 0); + +template <> +const Vector2i Vector2i::ex(1, 0); + +template <> +const Vector2i Vector2i::ey(0, 1); + +template <> +const Vector2i Vector2i::ones(1, 1); + +template <> +const Vector3i Vector3i::zero(0, 0, 0); + +template <> +const Vector3i Vector3i::ex(1, 0, 0); + +template <> +const Vector3i Vector3i::ey(0, 1, 0); + +template <> +const Vector3i Vector3i::ez(0, 0, 1); + +template <> +const Vector3i Vector3i::ones(1, 1, 1); + +template <> +const Vector4i Vector4i::zero(0, 0, 0, 0); + +template <> +const Vector4i Vector4i::ex(1, 0, 0, 0); + +template <> +const Vector4i Vector4i::ey(0, 1, 0, 0); + +template <> +const Vector4i Vector4i::ez(0, 0, 1, 0); + +template <> +const Vector4i Vector4i::ew(0, 0, 0, 1); + +template <> +const Vector4i Vector4i::ones(1, 1, 1, 1); + +template <> +const Vector2u Vector2u::zero(0u, 0u); + +template <> +const Vector2u Vector2u::ex(1u, 0u); + +template <> +const Vector2u Vector2u::ey(0u, 1u); + +template <> +const Vector2u Vector2u::ones(1u, 1u); + +template <> +const Vector3u Vector3u::zero(0u, 0u, 0u); + +template <> +const Vector3u Vector3u::ex(1u, 0u, 0u); + +template <> +const Vector3u Vector3u::ey(0u, 1u, 0u); + +template <> +const Vector3u Vector3u::ez(0u, 0u, 1u); + +template <> +const Vector3u Vector3u::ones(1u, 1u, 1u); + +template <> +const Vector4u Vector4u::zero(0u, 0u, 0u, 0u); + +template <> +const Vector4u Vector4u::ex(1u, 0u, 0u, 0u); + +template <> +const Vector4u Vector4u::ey(0u, 1u, 0u, 0u); + +template <> +const Vector4u Vector4u::ez(0u, 0u, 1u, 0u); + +template <> +const Vector4u Vector4u::ew(0u, 0u, 0u, 1u); + +template <> +const Vector4u Vector4u::ones(1u, 1u, 1u, 1u); } // namespace sead