Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A first pass over m3d #13

Merged
merged 35 commits into from
Sep 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
da31523
A first pass over m3d
robojumper Jun 20, 2024
aa372b1
d_a_obj_ring OK
robojumper Jun 20, 2024
f0e8914
m3d::calcRatio_c
robojumper Jun 20, 2024
c0b3821
m_mdl cleanup
robojumper Jun 20, 2024
669c428
m_anmtexsrt
robojumper Jun 21, 2024
fd4a600
d_a_obj_sun_light OK
robojumper Jun 21, 2024
5014135
m_anmChr OK
robojumper Jun 21, 2024
15a8177
m_anmChrBlend OK
robojumper Jun 21, 2024
a4d16c8
m_anmMatClr_c OK
robojumper Jun 21, 2024
144c874
anmTexPat_c OK
robojumper Jun 21, 2024
9b9d760
proc_c OK
robojumper Jun 21, 2024
0183069
anmMdl_c, anmShp_c OK
robojumper Jun 22, 2024
1a5dfa2
Cleanup and progress
robojumper Jun 22, 2024
1d9827c
m_mdl "OK"
robojumper Jun 23, 2024
4c6b151
cleanup
robojumper Jun 23, 2024
b43adc8
m_fanm OK
robojumper Jun 23, 2024
11eed4b
simpler fanm match (thank you LagoLunatic!)
robojumper Jun 23, 2024
4797d9e
m_scnmdl OK
robojumper Jun 23, 2024
5a5811a
dAcOmoleSoil_c OK
robojumper Jun 25, 2024
25cf783
d_a_obj_smoke
robojumper Jun 25, 2024
df9010f
dAcOlavaF200_c OK
robojumper Jun 25, 2024
2f32c5b
Fix create return values
robojumper Jun 26, 2024
3fd8ac3
d_a_e_hb_leaf OK
robojumper Jun 28, 2024
548da27
Cleanup
robojumper Jul 1, 2024
a3a8396
Rebase/warning fixes
robojumper Jul 1, 2024
66a7b0a
Don't reinvent SpawnStruct
robojumper Jul 5, 2024
5728051
Update m3d
elijah-thomas774 Sep 9, 2024
16bca79
Merge branch 'main' into m3d
elijah-thomas774 Sep 9, 2024
51fe00e
fix extern
elijah-thomas774 Sep 9, 2024
ed5fe5c
fix CopiedMatAccess size
elijah-thomas774 Sep 9, 2024
37da66e
Added m3d bline_c
elijah-thomas774 Sep 11, 2024
6fed118
m3d matching + some EGG declarations
elijah-thomas774 Sep 12, 2024
1085063
bline progress, stopping for now
elijah-thomas774 Sep 12, 2024
bd2a5f1
Merge branch 'main' into m3d
elijah-thomas774 Sep 12, 2024
48d627f
temp from a Dowsing PR merge
elijah-thomas774 Sep 12, 2024
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
Prev Previous commit
Next Next commit
m_mdl "OK"
robojumper committed Jul 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 1d9827cdb07898086fedc5e3aa0a3dd333bb706c
2 changes: 1 addition & 1 deletion config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
@@ -22199,7 +22199,7 @@ PSMTXTrans = .text:0x803B8770; // type:function size:0x34
fn_803B87B0 = .text:0x803B87B0; // type:function size:0x4C
fn_803B8800 = .text:0x803B8800; // type:function size:0x28
fn_803B8830 = .text:0x803B8830; // type:function size:0x58
fn_803B8890 = .text:0x803B8890; // type:function size:0xA4
PSMTXQuat = .text:0x803B8890; // type:function size:0xA4
fn_803B8940 = .text:0x803B8940; // type:function size:0x174
fn_803B8AC0 = .text:0x803B8AC0; // type:function size:0xA4
C_MTXLightPerspective = .text:0x803B8B70; // type:function size:0xF8
2 changes: 1 addition & 1 deletion configure.py
Original file line number Diff line number Diff line change
@@ -349,7 +349,7 @@ def nw4rLib(lib_name, objects, extra_cflags=[]):
Object(NonMatching, "m/m3d/m_bmdl.cpp"),
Object(Matching, "m/m3d/m_calc_ratio.cpp"),
Object(NonMatching, "m/m3d/m_fanm.cpp"),
Object(NonMatching, "m/m3d/m_mdl.cpp"),
Object(Matching, "m/m3d/m_mdl.cpp"),
Object(NonMatching, "m/m3d/m_scnLeaf.cpp"),
Object(Matching, "m/m3d/m_smdl.cpp"),
Object(Matching, "m/m_allocator.cpp"),
5 changes: 1 addition & 4 deletions include/m/m3d/m_mdl.h
Original file line number Diff line number Diff line change
@@ -22,10 +22,7 @@ class callback_c {

class mdl_c : public smdl_c {
public:
// TODO this is not the correct callback class, since NSMBW has
// the A, B, C names and also the _CALC_X from IScnObjCallback,
// so there must be a different callback interface
class mdlCallback_c : public nw4r::g3d::IScnObjCallback {
class mdlCallback_c : public nw4r::g3d::ICalcWorldCallback {
public:
mdlCallback_c();
virtual ~mdlCallback_c();
11 changes: 11 additions & 0 deletions include/nw4r/g3d/g3d_calcworld.h
Original file line number Diff line number Diff line change
@@ -23,6 +23,17 @@ struct FuncObjCalcWorld {

class WorldMtxManip {};

// Name from ketteiban
class ICalcWorldCallback {
public:
virtual ~ICalcWorldCallback() {}

virtual void ExecCallbackA(nw4r::g3d::ChrAnmResult *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *) {}
virtual void ExecCallbackB(nw4r::g3d::WorldMtxManip *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *) {}
virtual void ExecCallbackC(nw4r::math::MTX34 *, nw4r::g3d::ResMdl, nw4r::g3d::FuncObjCalcWorld *) {}
};


void CalcWorld(math::MTX34 *, u32 *, const u8 *, const math::MTX34 *, ResMdl, AnmObjChr *, FuncObjCalcWorld *, u32);

void CalcWorld(math::MTX34 *, u32 *, const u8 *, const math::MTX34 *, ResMdl, AnmObjChr *, FuncObjCalcWorld *);
7 changes: 7 additions & 0 deletions include/nw4r/g3d/g3d_scnmdlsmpl.h
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
#include "nw4r/math/math_types.h"
#include "nw4r/g3d/g3d_resmdl.h"
#include "nw4r/g3d/g3d_scnobj.h"
#include "nw4r/g3d/g3d_calcworld.h"

namespace nw4r {
namespace g3d {
@@ -75,6 +76,10 @@ class ScnMdlSimple : public ScnLeaf {
return mNumViewMtx;
}

void SetCalcWorldCallback(ICalcWorldCallback *cb) {
mpCalcWorldCallback = cb;
}

private:
ResMdl mResMdl; // at 0xE8
math::MTX34 *mWldMatrixArray; // at 0xEC
@@ -90,6 +95,8 @@ class ScnMdlSimple : public ScnLeaf {
void *mByteCodeMix; // at 0x10C
void *mByteCodeDrawOpa; // at 0x110
void *mByteCodeDrawXlu; // at 0x114
UNKWORD WORD_0x118;
ICalcWorldCallback *mpCalcWorldCallback; // at 0x11C

NW4R_G3D_TYPE_OBJ_DECL(ScnMdlSimple);
};
46 changes: 33 additions & 13 deletions src/m/m3d/m_mdl.cpp
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@ mdl_c::mdlCallback_c::~mdlCallback_c() {}

void mdl_c::mdlCallback_c::ExecCallbackA(nw4r::g3d::ChrAnmResult *result, nw4r::g3d::ResMdl mdl,
nw4r::g3d::FuncObjCalcWorld *o) {
nw4r::g3d::ChrAnmResult *resPtr = &mpNodes[o->GetNodeId()];
u16 nodeId = o->GetNodeId();
nw4r::g3d::ChrAnmResult *resPtr = &mpNodes[nodeId];
if (mCalcRatio.is0x18() && !mCalcRatio.isEnd()) {
if (!mCalcRatio.is0x19()) {
*result = *resPtr;
@@ -23,7 +24,8 @@ void mdl_c::mdlCallback_c::ExecCallbackA(nw4r::g3d::ChrAnmResult *result, nw4r::
f32 f2 = mCalcRatio.get0x10();
f32 f1 = mCalcRatio.get0x14();

// TODO the math operators cause ps inline assembly
// TODO clean up this code, what does it even do, why do operators
// break
if ((flags & 8) == 0) {
result->VEC3_0x4.x = (result->VEC3_0x4.x * f1 + resPtr->VEC3_0x4.x * f2);
result->VEC3_0x4.y = (result->VEC3_0x4.y * f1 + resPtr->VEC3_0x4.y * f2);
@@ -36,8 +38,8 @@ void mdl_c::mdlCallback_c::ExecCallbackA(nw4r::g3d::ChrAnmResult *result, nw4r::

nw4r::math::QUAT q1;
nw4r::math::QUAT q2;

C_QUATMtx(q1, resPtr->mMtx);
// TODO ...
if ((flags & 0x20) == 0) {
C_QUATMtx(q2, result->mMtx);
} else {
@@ -46,20 +48,36 @@ void mdl_c::mdlCallback_c::ExecCallbackA(nw4r::g3d::ChrAnmResult *result, nw4r::
q2.z = 0.0f;
q2.w = 1.0f;
}
nw4r::math::QUAT q3;
C_QUATSlerp(q1, q2, q3, f1);
PSMTXQuat(result->mMtx, q3);
result->VEC3_0x10 = (flags & 0x40) == 0 ?
nw4r::math::VEC3(result->VEC3_0x10.x * f1, result->VEC3_0x10.y * f1, result->VEC3_0x10.z * f1) :
result->VEC3_0x10;

C_QUATSlerp(q1, q2, q1, f1);
// TODO weird hacks to force register order, probably more inlines
f32 tmp3, tmp2, tmp1;
tmp1 = result->mMtx._03;
tmp2 = result->mMtx._13;
tmp3 = result->mMtx._23;
nw4r::math::VEC3 tmp(tmp1, tmp2, tmp3);
PSMTXQuat(result->mMtx, q1);
result->mMtx._03 = tmp.x;
result->mMtx._13 = tmp.y;
result->mMtx._23 = tmp.z;
if ((flags & 0x40) == 0) {
result->mMtx._03 = tmp.x * f1;
result->mMtx._13 = tmp.y * f1;
result->mMtx._23 = tmp.z * f1;
}
u32 flags2 = result->mFlags & ~(0x80000000 | 0x80000040 | 0x80000020 | 0x80000008);
result->mMtx._03 += resPtr->mMtx._03 * f2;
result->mMtx._13 += resPtr->mMtx._13 * f2;
result->mMtx._23 += resPtr->mMtx._23 * f2;
result->mFlags = flags2;
*resPtr = *result;
}
} else {
*resPtr = *result;
}

if (mpBaseCallback != nullptr) {
mpBaseCallback->timingA(mNumNode, result, mdl);
mpBaseCallback->timingA(nodeId, result, mdl);
}
}

@@ -69,9 +87,11 @@ void mdl_c::mdlCallback_c::ExecCallbackB(nw4r::g3d::WorldMtxManip *m, nw4r::g3d:
if (mpBaseCallback != nullptr) {
mpBaseCallback->timingB(nodeId, m, mdl);
}
// Not sure what this does
u32 num = mdl.GetResNodeNumEntries();
u32 numInc = num + 1;
o->SetNodeId(numInc - (numInc / num) * num);
u32 nodeInc = nodeId + 1;
u32 tmp = (nodeInc / num);
o->SetNodeId(nodeInc - tmp * num);
}

void mdl_c::mdlCallback_c::ExecCallbackC(nw4r::math::MTX34 *mat, nw4r::g3d::ResMdl mdl, nw4r::g3d::FuncObjCalcWorld *) {
@@ -185,7 +205,7 @@ bool mdl_c::create(nw4r::g3d::ResMdl mdl, mdl_c::mdlCallback_c *cb, mAllocator_c
}
nw4r::g3d::ScnMdlSimple *sMdl;
sMdl = nw4r::g3d::G3dObj::DynamicCast<nw4r::g3d::ScnMdlSimple>(mpScnLeaf);
sMdl->SetCallback(mpCallback);
sMdl->SetCalcWorldCallback(mpCallback);
sMdl->EnableScnObjCallbackTiming(nw4r::g3d::ScnObj::TIMING_ALL);
setCallback(nullptr);
return true;