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
31 changes: 31 additions & 0 deletions include/JSystem/JGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,37 @@ struct TBox2 : public TBox<TVec2<T> > {

// clang-format on

// Row-major storage: at()/ref() are transposed relative to SMatrix33C, so
// setting a direction writes three contiguous floats.
template <typename T>
struct SMatrix33R {
T mMtx[3][3];
};

template <>
struct SMatrix33R<f32> {
SMatrix33R() {}

f32 at(u32 i, u32 j) const { return mMtx[j][i]; }
f32& ref(u32 i, u32 j) { return mMtx[j][i]; }

f32 mMtx[3][3];
};

template <typename T>
struct TMatrix33 : public T {
TMatrix33() {}

void mult(const TVec3<f32>& src, TVec3<f32>& dst) const {
dst.set(this->at(0, 0) * src.x + this->at(0, 1) * src.y + this->at(0, 2) * src.z,
this->at(1, 0) * src.x + this->at(1, 1) * src.y + this->at(1, 2) * src.z,
this->at(2, 0) * src.x + this->at(2, 1) * src.y + this->at(2, 2) * src.z);
}

void mult(TVec3<f32>& v) const { mult(v, v); }
};


} // namespace JGeometry

#endif
15 changes: 14 additions & 1 deletion include/JSystem/TPosition3.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define TPOSITION3_H

#include "dolphin/mtx/mtx.h"
#include "JSystem/JGeometry.h"
#include "JSystem/JMath/JMath.h"

namespace JGeometry {
Expand All @@ -28,7 +29,19 @@ template <typename T>
struct TMatrix34 : public T {};

template <typename T>
struct TRotation3 : public T {};
struct TRotation3 : public T {
void setXYZDir(const TVec3<f32>& x, const TVec3<f32>& y, const TVec3<f32>& z) {
this->ref(0, 0) = x.x;
this->ref(1, 0) = x.y;
this->ref(2, 0) = x.z;
this->ref(0, 1) = y.x;
this->ref(1, 1) = y.y;
this->ref(2, 1) = y.z;
this->ref(0, 2) = z.x;
this->ref(1, 2) = z.y;
this->ref(2, 2) = z.z;
}
};

template <typename T>
struct TPosition3 : public T {};
Expand Down
Loading
Loading