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
2 changes: 2 additions & 0 deletions include/math/seadMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,8 @@ class Matrix34 : public Policies<T>::Mtx34Base
Vec3 getRotation() const;

void getBase(Vec3& o, s32 axis) const;
template <s32 Axis>
void getBase(Vec3& o) const;
void getRow(Vec4& o, s32 row) const;
void getTranslation(Vec3& o) const;
void getRotation(Vec3& o) const;
Expand Down
7 changes: 7 additions & 0 deletions include/math/seadMatrix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,13 @@ inline void Matrix34<T>::getBase(Vec3& o, s32 axis) const
Matrix34CalcCommon<T>::getBase(o, *this, axis);
}

template <typename T>
template <s32 Axis>
inline void Matrix34<T>::getBase(Vec3& o) const
{
Matrix34CalcCommon<T>::template getBase<Axis>(o, *this);
}

template <typename T>
inline void Matrix34<T>::getRow(Vec4& o, s32 row) const
{
Expand Down
2 changes: 2 additions & 0 deletions include/math/seadMatrixCalcCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class Matrix34CalcCommon
static void toQuat(Quat& q, const Base& n);

static void getBase(Vec3& v, const Base& n, s32 axis);
template <s32 Axis>
static void getBase(Vec3& v, const Base& n);
static void getRow(Vec4& v, const Base& n, s32 row);
static void getTranslation(Vec3& v, const Base& n);
static void getRotation(Vec3& v, const Base& n);
Expand Down
33 changes: 33 additions & 0 deletions include/math/seadMatrixCalcCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#ifdef __aarch64__
#include <arm_neon.h>
#include <prim/seadMemUtil.h>
#endif

#include <cmath>
Expand Down Expand Up @@ -1807,6 +1808,38 @@ void Matrix34CalcCommon<T>::getBase(Vec3& v, const Base& n, s32 axis)
v.z = n.m[2][axis];
}

template <typename T>
template <s32 Axis>
void Matrix34CalcCommon<T>::getBase(Vec3& v, const Base& n)
{
v.x = n.m[0][Axis];
v.y = n.m[1][Axis];
v.z = n.m[2][Axis];
}

#ifdef __aarch64__
template <>
template <s32 Axis>
void Matrix34CalcCommon<f32>::getBase(Vec3& v, const Base& n)
{
const f32* next_row;
if (Axis == 0)
next_row = &n.m[1][Axis];

f32 first;
__atomic_load(&n.m[0][Axis], &first, __ATOMIC_RELAXED);
float32x2_t xy = {first, 0.0f};

if (Axis != 0)
next_row = &n.m[1][Axis];

xy[1] = *next_row;
const f32 z = n.m[2][Axis];
MemUtil::copy(&v.x, &xy, sizeof(xy));
v.z = z;
}
#endif

template <typename T>
void Matrix34CalcCommon<T>::getRow(Vec4& v, const Base& n, s32 row)
{
Expand Down