Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/basis/seadTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
22 changes: 12 additions & 10 deletions include/math/seadMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ typedef Matrix22<f32> Matrix22f;
typedef Matrix33<f32> Matrix33f;
typedef Matrix34<f32> Matrix34f;
typedef Matrix44<f32> Matrix44f;

typedef Matrix34<f32> Matrixf;
typedef Matrix22<f64> Matrix22d;
typedef Matrix33<f64> Matrix33d;
typedef Matrix34<f64> Matrix34d;
typedef Matrix44<f64> Matrix44d;

template <>
const Matrix22f Matrix22f::zero;
Expand All @@ -303,28 +305,28 @@ template <>
const Matrix44f Matrix44f::ident;

template <>
const Matrix22<f64> Matrix22<f64>::zero;
const Matrix22d Matrix22d::zero;

template <>
const Matrix22<f64> Matrix22<f64>::ident;
const Matrix22d Matrix22d::ident;

template <>
const Matrix33<f64> Matrix33<f64>::zero;
const Matrix33d Matrix33d::zero;

template <>
const Matrix33<f64> Matrix33<f64>::ident;
const Matrix33d Matrix33d::ident;

template <>
const Matrix34<f64> Matrix34<f64>::zero;
const Matrix34d Matrix34d::zero;

template <>
const Matrix34<f64> Matrix34<f64>::ident;
const Matrix34d Matrix34d::ident;

template <>
const Matrix44<f64> Matrix44<f64>::zero;
const Matrix44d Matrix44d::zero;

template <>
const Matrix44<f64> Matrix44<f64>::ident;
const Matrix44d Matrix44d::ident;

template <typename T>
bool operator==(const Matrix34<T>& lhs, const Matrix34<T>& rhs);
Expand Down
13 changes: 13 additions & 0 deletions include/math/seadVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ struct Vector2 : public Policies<T>::Vec2Base
Vector2() {}
Vector2(const Vector2& other) = default;
Vector2(T x, T y);
template <typename U>
Vector2(const Vector2<U>& other) : Vector2((T)other.x, (T)other.y)
{
}

Vector2& operator=(const Vector2& other);

Expand Down Expand Up @@ -88,6 +92,10 @@ struct Vector3 : public Policies<T>::Vec3Base
Vector3() {}
Vector3(const Vector3& other) = default;
Vector3(T x, T y, T z);
template <typename U>
Vector3(const Vector3<U>& other) : Vector3((T)other.x, (T)other.y, (T)other.z)
{
}

Vector3& operator=(const Vector3& other);
bool operator==(const Vector3& rhs) const;
Expand Down Expand Up @@ -143,6 +151,7 @@ struct Vector3 : public Policies<T>::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
{
Expand Down Expand Up @@ -204,6 +213,10 @@ struct Vector4 : public Policies<T>::Vec4Base
Vector4() {}
Vector4(const Vector4& other) = default;
Vector4(T x, T y, T z, T w);
template <typename U>
Vector4(const Vector4<U>& other) : Vector4((T)other.x, (T)other.y, (T)other.z, (T)other.w)
{
}

Vector4& operator=(const Vector4& other);

Expand Down
42 changes: 22 additions & 20 deletions modules/src/math/seadMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,55 +3,57 @@
namespace sead
{
template <>
const Matrix22<f32> Matrix22<f32>::zero(0.0f, 0.0f, 0.0f, 0.0f);
const Matrix22f Matrix22f::zero(0.0f, 0.0f, 0.0f, 0.0f);

template <>
const Matrix22<f32> Matrix22<f32>::ident(1.0f, 0.0f, 0.0f, 1.0f);
const Matrix22f Matrix22f::ident(1.0f, 0.0f, 0.0f, 1.0f);

template <>
const Matrix33<f32> Matrix33<f32>::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<f32> Matrix33<f32>::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<f32> Matrix34<f32>::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<f32> Matrix34<f32>::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<f32> Matrix44<f32>::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<f32> Matrix44<f32>::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<f64> Matrix22<f64>::zero(0, 0, 0, 0);
const Matrix22d Matrix22d::zero(0.0, 0.0, 0.0, 0.0);

template <>
const Matrix22<f64> Matrix22<f64>::ident(1, 0, 0, 1);
const Matrix22d Matrix22d::ident(1.0, 0.0, 0.0, 1.0);

template <>
const Matrix33<f64> Matrix33<f64>::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<f64> Matrix33<f64>::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<f64> Matrix34<f64>::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<f64> Matrix34<f64>::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<f64> Matrix44<f64>::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<f64> Matrix44<f64>::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
2 changes: 1 addition & 1 deletion modules/src/math/seadQuat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
namespace sead
{
template <>
const Quatf Quat<float>::unit(1.0f, 0.0f, 0.0f, 0.0f);
const Quatf Quatf::unit(1.0f, 0.0f, 0.0f, 0.0f);
} // namespace sead
120 changes: 105 additions & 15 deletions modules/src/math/seadVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,138 @@
namespace sead
{
template <>
const Vector2<f32> Vector2<f32>::zero(0.0f, 0.0f);
const Vector2f Vector2f::zero(0.0f, 0.0f);

template <>
const Vector2<f32> Vector2<f32>::ex(1.0f, 0.0f);
const Vector2f Vector2f::ex(1.0f, 0.0f);

template <>
const Vector2<f32> Vector2<f32>::ey(0.0f, 1.0f);
const Vector2f Vector2f::ey(0.0f, 1.0f);

template <>
const Vector2<f32> Vector2<f32>::ones(1.0f, 1.0f);
const Vector2f Vector2f::ones(1.0f, 1.0f);

template <>
const Vector3<f32> Vector3<f32>::zero(0.0f, 0.0f, 0.0f);
const Vector3f Vector3f::zero(0.0f, 0.0f, 0.0f);

template <>
const Vector3<f32> Vector3<f32>::ex(1.0f, 0.0f, 0.0f);
const Vector3f Vector3f::ex(1.0f, 0.0f, 0.0f);

template <>
const Vector3<f32> Vector3<f32>::ey(0.0f, 1.0f, 0.0f);
const Vector3f Vector3f::ey(0.0f, 1.0f, 0.0f);

template <>
const Vector3<f32> Vector3<f32>::ez(0.0f, 0.0f, 1.0f);
const Vector3f Vector3f::ez(0.0f, 0.0f, 1.0f);

template <>
const Vector3<f32> Vector3<f32>::ones(1.0f, 1.0f, 1.0f);
const Vector3f Vector3f::ones(1.0f, 1.0f, 1.0f);

template <>
const Vector4<f32> Vector4<f32>::zero(0.0f, 0.0f, 0.0f, 0.0f);
const Vector4f Vector4f::zero(0.0f, 0.0f, 0.0f, 0.0f);

template <>
const Vector4<f32> Vector4<f32>::ex(1.0f, 0.0f, 0.0f, 0.0f);
const Vector4f Vector4f::ex(1.0f, 0.0f, 0.0f, 0.0f);

template <>
const Vector4<f32> Vector4<f32>::ey(0.0f, 1.0f, 0.0f, 0.0f);
const Vector4f Vector4f::ey(0.0f, 1.0f, 0.0f, 0.0f);

template <>
const Vector4<f32> Vector4<f32>::ez(0.0f, 0.0f, 1.0f, 0.0f);
const Vector4f Vector4f::ez(0.0f, 0.0f, 1.0f, 0.0f);

template <>
const Vector4<f32> Vector4<f32>::ew(0.0f, 0.0f, 0.0f, 1.0f);
const Vector4f Vector4f::ew(0.0f, 0.0f, 0.0f, 1.0f);

template <>
const Vector4<f32> Vector4<f32>::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
Loading