J3DJointTree OK

This commit is contained in:
Jasper St. Pierre
2022-12-30 14:09:21 -08:00
parent 463348bfc7
commit 0ff72d731b
6 changed files with 113 additions and 268 deletions
+97 -115
View File
@@ -4,101 +4,11 @@
//
#include "JSystem/J3DGraphAnimator/J3DJointTree.h"
#include "JSystem/J3DGraphAnimator/J3DMaterialAttach.h"
#include "JSystem/J3DGraphAnimator/J3DShapeTable.h"
#include "dol2asm.h"
#include "dolphin/types.h"
//
// Forward References:
//
extern "C" void __ct__12J3DJointTreeFv();
extern "C" void
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable();
extern "C" void findImportantMtxIndex__12J3DJointTreeFv();
extern "C" void calc__12J3DJointTreeFP12J3DMtxBufferRC3VecRA3_A4_Cf();
extern "C" void setMtxBuffer__10J3DMtxCalcFP12J3DMtxBuffer();
extern "C" void __dt__12J3DJointTreeFv();
//
// External References:
//
extern "C" void __dl__FPv();
extern "C" void __ct__14J3DDrawMtxDataFv();
extern "C" void __dt__14J3DDrawMtxDataFv();
extern "C" void appendChild__8J3DJointFP8J3DJoint();
extern "C" void recursiveCalc__8J3DJointFv();
extern "C" void _savegpr_23();
extern "C" void _restgpr_23();
extern "C" u8 mMtxBuffer__10J3DMtxCalc[4];
extern "C" u8 mCurrentMtxCalc__8J3DJoint[4 + 4 /* padding */];
//
// Declarations:
//
/* ############################################################################################## */
/* 803CECA8-803CECF4 -00001 004C+00 1/1 0/0 0/0 .data @871 */
SECTION_DATA static void* lit_871[19] = {
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0x90),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0x60),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0x84),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xE4),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0x94),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xB0),
(void*)(((char*)
makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable) +
0xCC),
};
/* 80325A18-80325A9C 320358 0084+00 0/0 1/1 0/0 .text __ct__12J3DJointTreeFv */
J3DJointTree::J3DJointTree()
: mHierarchy(NULL), mFlags(0), mModelDataType(0), mRootNode(NULL), mBasicMtxCalc(NULL),
@@ -109,33 +19,105 @@ J3DJointTree::J3DJointTree()
/* 80325A9C-80325C00 3203DC 0164+00 1/0 2/2 0/0 .text
* makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable
*/
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void J3DJointTree::makeHierarchy(J3DJoint* param_0, J3DModelHierarchy const** param_1,
J3DMaterialTable* param_2, J3DShapeTable* param_3) {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DJointTree/func_80325A9C.s"
}
#pragma pop
void J3DJointTree::makeHierarchy(J3DJoint* pJoint, J3DModelHierarchy const** pHierarchy,
J3DMaterialTable* pMaterialTable, J3DShapeTable* pShapeTable) {
enum {
kTypeEnd = 0x00,
kTypeBeginChild = 0x01,
kTypeEndChild = 0x02,
kTypeJoint = 0x10,
kTypeMaterial = 0x11,
kTypeShape = 0x12,
};
/* ############################################################################################## */
/* 80456418-80456420 004A18 0004+04 1/1 0/0 0/0 .sdata2 @903 */
SECTION_SDATA2 static f32 lit_903[1 + 1 /* padding */] = {
-1.0f / 10.0f,
/* padding */
0.0f,
};
J3DJoint * curJoint = pJoint;
while (true) {
J3DJoint * newJoint = NULL;
J3DMaterial * newMaterial = NULL;
J3DShape * newShape = NULL;
const J3DModelHierarchy * inf = *pHierarchy;
u16 val;
switch (inf->mType) {
case kTypeBeginChild:
*pHierarchy = inf + 1;
makeHierarchy(curJoint, pHierarchy, pMaterialTable, pShapeTable);
break;
case kTypeEndChild:
*pHierarchy = inf + 1;
return;
case kTypeEnd:
return;
case kTypeJoint:
{
J3DJoint ** jointNodePointer = mJointNodePointer;
*pHierarchy = inf + 1;
newJoint = jointNodePointer[inf->mValue];
}
break;
case kTypeMaterial:
*pHierarchy = inf + 1;
val = inf->mValue;
newMaterial = pMaterialTable->getMaterialNodePointer(val);
break;
case kTypeShape:
*pHierarchy = inf + 1;
val = inf->mValue;
newShape = pShapeTable->getShapeNodePointer(val);
break;
}
if (newJoint != NULL) {
curJoint = newJoint;
if (pJoint == NULL)
mRootNode = newJoint;
else
pJoint->appendChild(newJoint);
} else if (newMaterial != NULL) {
if (pJoint->getMesh() != NULL)
newMaterial->mNext = pJoint->getMesh();
pJoint->mMesh = newMaterial;
newMaterial->mJoint = pJoint;
} else if (newShape != NULL) {
newMaterial = pJoint->getMesh();
newMaterial->mShape = newShape;
newShape->mMaterial = newMaterial;
}
}
}
/* 80325C00-80325CAC 320540 00AC+00 0/0 2/2 0/0 .text findImportantMtxIndex__12J3DJointTreeFv */
#pragma push
#pragma optimization_level 0
#pragma optimizewithasm off
asm void J3DJointTree::findImportantMtxIndex() {
nofralloc
#include "asm/JSystem/J3DGraphAnimator/J3DJointTree/findImportantMtxIndex__12J3DJointTreeFv.s"
void J3DJointTree::findImportantMtxIndex() {
const s32 wEvlpMtxNum = getWEvlpMtxNum();
u32 tableIdx = 0;
const u16 drawFullWgtMtxNum = getDrawFullWgtMtxNum();
const u16 * wEvlpMixIndex = getWEvlpMixIndex();
const f32 * wEvlpMixWeight = getWEvlpMixWeight();
u16 * wEvlpImportantMtxIdx = getWEvlpImportantMtxIndex();
// Rigid matrices are easy.
for (u16 i = 0; i < drawFullWgtMtxNum; i++)
wEvlpImportantMtxIdx[i] = mDrawMtxData.mDrawMtxIndex[i];
// For envelope matrices, we need to find the matrix with the most contribution.
for (s32 i = 0; i < wEvlpMtxNum; i++) {
s32 mixNum = getWEvlpMixMtxNum(i);
u16 bestIdx = 0;
f32 bestWeight = -0.1f;
for (s32 j = 0; j < mixNum; j++) {
if (bestWeight < wEvlpMixWeight[tableIdx]) {
bestWeight = wEvlpMixWeight[tableIdx];
bestIdx = wEvlpMixIndex[tableIdx];
}
tableIdx++;
}
wEvlpImportantMtxIdx[i + mDrawMtxData.mDrawFullWgtMtxNum] = bestIdx;
}
}
#pragma pop
/* 80325CAC-80325D1C 3205EC 0070+00 1/0 0/0 0/0 .text
* calc__12J3DJointTreeFP12J3DMtxBufferRC3VecRA3_A4_Cf */