Skip to content
Closed
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: 1 addition & 1 deletion config/SOUE01/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5013,7 +5013,7 @@ egg/math/eggMath.cpp:
egg/math/eggMatrix.cpp:
.text start:0x8049AC70 end:0x8049B388 align:16
.ctors start:0x804DB990 end:0x804DB994
.sdata2 start:0x8057F368 end:0x8057F380
.sdata2 start:0x8057F368 end:0x8057F37C
.bss start:0x80674C00 end:0x80674C30

egg/math/eggQuat.cpp:
Expand Down
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ def MatchingFor(*versions):
"math",
[
Object(NonMatching, "egg/math/eggMath.cpp"),
Object(NonMatching, "egg/math/eggMatrix.cpp"),
Object(Matching, "egg/math/eggMatrix.cpp"),
Object(NonMatching, "egg/math/eggQuat.cpp"),
Object(Matching, "egg/math/eggVector.cpp"),
],
Expand Down
19 changes: 12 additions & 7 deletions src/egg/math/eggMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,22 @@ void Matrix34f::makeT(const Vector3f &t) {
m[2][3] = t.z;
}

static inline f32 getQuatW(const Quatf &q) { return q.w; }
static inline f32 getQuatX(const Quatf &q) { return q.v.x; }
static inline f32 getQuatY(const Quatf &q) { return q.v.y; }
static inline f32 getQuatZ(const Quatf &q) { return q.v.z; }

void Matrix34f::fromQuat(const Quatf &q) {
m[0][0] = 1.0f - (2 * q.v.y * q.v.y) - (2.0f * q.v.z * q.v.z);
m[0][1] = (2.0f * q.v.x * q.v.y) - (2.0f * q.w * q.v.z);
m[0][2] = (2.0f * q.v.x * q.v.z) + (2.0f * q.w * q.v.y);
m[0][1] = (2.0f * q.v.x * q.v.y) - (2.0f * getQuatW(q) * getQuatZ(q));
m[0][2] = (2.0f * q.v.x * q.v.z) + (2.0f * getQuatW(q) * getQuatY(q));

m[1][0] = (2.0f * q.v.x * q.v.y) + (2.0f * q.w * q.v.z);
m[1][0] = (2.0f * q.v.x * q.v.y) + (2.0f * getQuatW(q) * getQuatZ(q));
m[1][1] = 1.0f - (2.0f * q.v.x * q.v.x) - (2.0f * q.v.z * q.v.z);
m[1][2] = (2.0f * q.v.y * q.v.z) - (2.0f * q.w * q.v.x);
m[1][2] = (2.0f * q.v.y * q.v.z) - (2.0f * getQuatW(q) * getQuatX(q));

m[2][0] = (2.0f * q.v.x * q.v.z) - (2.0f * q.w * q.v.y);
m[2][1] = (2.0f * q.v.y * q.v.z) + (2.0f * q.w * q.v.x);
m[2][0] = (2.0f * q.v.x * q.v.z) - (2.0f * getQuatW(q) * getQuatY(q));
m[2][1] = (2.0f * q.v.y * q.v.z) + (2.0f * getQuatW(q) * getQuatX(q));
m[2][2] = 1.0f - (2.0f * q.v.x * q.v.x) - (2.0f * q.v.y * q.v.y);

m[2][3] = 0.0f;
Expand Down Expand Up @@ -329,7 +334,7 @@ void Matrix34f::toQuat(Quatf &q) const {
q.v.y = -q.v.y;
q.v.z = -q.v.z;
}
q.multScalar(Math<f32>::inv(Math<f32>::sqrt(q.w * q.w + q.v.dot(q.v))));
q.multScalar(Math<f32>::inv(Math<f32>::sqrt(q.w * q.w + q.v.x * q.v.x + q.v.y * q.v.y + q.v.z * q.v.z)));
}

void Matrix34f::slerpTo(const Matrix34f &m2, Matrix34f &out, f32 t) const {
Expand Down
Loading