diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2025-09-04 07:56:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-04 17:56:59 +0300 |
| commit | b45a089e15d79821b07be020db628e01a49b1fd2 (patch) | |
| tree | 948057548cc19b19d644bd4f300ca6434e6bff11 /src/JSystem/J3DGraphAnimator/J3DJointTree.cpp | |
| parent | ee8b843996f4d888903f8c125b95ec1af376877e (diff) | |
some J3D/misc cleanup (#2628)
* some j3d cleanup
* begin using uintptr_t
* j3dgraphbase cleanup
* j3dgraphanimator cleanup
Diffstat (limited to 'src/JSystem/J3DGraphAnimator/J3DJointTree.cpp')
| -rw-r--r-- | src/JSystem/J3DGraphAnimator/J3DJointTree.cpp | 90 |
1 files changed, 39 insertions, 51 deletions
diff --git a/src/JSystem/J3DGraphAnimator/J3DJointTree.cpp b/src/JSystem/J3DGraphAnimator/J3DJointTree.cpp index b9aaa4618b..9b6cae0b3b 100644 --- a/src/JSystem/J3DGraphAnimator/J3DJointTree.cpp +++ b/src/JSystem/J3DGraphAnimator/J3DJointTree.cpp @@ -3,6 +3,15 @@ #include "JSystem/J3DGraphAnimator/J3DShapeTable.h" #include "JSystem/J3DGraphBase/J3DMaterial.h" +enum { + kTypeEnd = 0x00, + kTypeBeginChild = 0x01, + kTypeEndChild = 0x02, + kTypeJoint = 0x10, + kTypeMaterial = 0x11, + kTypeShape = 0x12, +}; + /* 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), @@ -13,52 +22,34 @@ J3DJointTree::J3DJointTree() /* 80325A9C-80325C00 3203DC 0164+00 1/0 2/2 0/0 .text * makeHierarchy__12J3DJointTreeFP8J3DJointPPC17J3DModelHierarchyP16J3DMaterialTableP13J3DShapeTable */ -void J3DJointTree::makeHierarchy(J3DJoint* pJoint, J3DModelHierarchy const** pHierarchy, +void J3DJointTree::makeHierarchy(J3DJoint* pJoint, const J3DModelHierarchy** pHierarchy, J3DMaterialTable* pMaterialTable, J3DShapeTable* pShapeTable) { - enum { - kTypeEnd = 0x00, - kTypeBeginChild = 0x01, - kTypeEndChild = 0x02, - kTypeJoint = 0x10, - kTypeMaterial = 0x11, - kTypeShape = 0x12, - }; - - J3DJoint * curJoint = pJoint; + J3D_ASSERT_NULLPTR(95, pHierarchy != NULL); + J3DJoint* curJoint = pJoint; while (true) { - J3DJoint * newJoint = NULL; - J3DMaterial * newMaterial = NULL; - J3DShape * newShape = NULL; - const J3DModelHierarchy * inf = *pHierarchy; - u16 val; + J3DJoint* newJoint = NULL; + J3DMaterial* newMaterial = NULL; + J3DShape* newShape = NULL; - switch (inf->mType) { + switch ((*pHierarchy)->mType) { case kTypeBeginChild: - *pHierarchy = inf + 1; + (*pHierarchy)++; makeHierarchy(curJoint, pHierarchy, pMaterialTable, pShapeTable); break; case kTypeEndChild: - *pHierarchy = inf + 1; + (*pHierarchy)++; return; case kTypeEnd: return; case kTypeJoint: - { - J3DJoint ** jointNodePointer = mJointNodePointer; - *pHierarchy = inf + 1; - newJoint = jointNodePointer[inf->mValue]; - } + newJoint = mJointNodePointer[((*pHierarchy)++)->mValue]; break; case kTypeMaterial: - *pHierarchy = inf + 1; - val = inf->mValue; - newMaterial = pMaterialTable->getMaterialNodePointer(val); + newMaterial = pMaterialTable->getMaterialNodePointer(((*pHierarchy)++)->mValue); break; case kTypeShape: - *pHierarchy = inf + 1; - val = inf->mValue; - newShape = pShapeTable->getShapeNodePointer(val); + newShape = pShapeTable->getShapeNodePointer(((*pHierarchy)++)->mValue); break; } @@ -68,31 +59,29 @@ void J3DJointTree::makeHierarchy(J3DJoint* pJoint, J3DModelHierarchy const** pHi 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; + } else if (newMaterial != NULL && pJoint->getType() == 'NJNT') { + pJoint->addMesh(newMaterial); + newMaterial->setJoint(pJoint); + } else if (newShape != NULL && pJoint->getType() == 'NJNT') { + J3DMaterial* newMaterial = pJoint->getMesh(); + newMaterial->addShape(newShape); + newShape->setMaterial(newMaterial); } } } /* 80325C00-80325CAC 320540 00AC+00 0/0 2/2 0/0 .text findImportantMtxIndex__12J3DJointTreeFv */ void J3DJointTree::findImportantMtxIndex() { - const s32 wEvlpMtxNum = getWEvlpMtxNum(); + s32 wEvlpMtxNum = getWEvlpMtxNum(); u32 tableIdx = 0; - const u16 drawFullWgtMtxNum = getDrawFullWgtMtxNum(); - const u16 * wEvlpMixIndex = getWEvlpMixMtxIndex(); - const f32 * wEvlpMixWeight = getWEvlpMixWeight(); - u16 * wEvlpImportantMtxIdx = getWEvlpImportantMtxIndex(); + u16 drawFullWgtMtxNum = getDrawFullWgtMtxNum(); + u16* wEvlpMixIndex = getWEvlpMixMtxIndex(); + f32* wEvlpMixWeight = getWEvlpMixWeight(); + u16* wEvlpImportantMtxIdx = getWEvlpImportantMtxIndex(); // Rigid matrices are easy. for (u16 i = 0; i < drawFullWgtMtxNum; i++) - wEvlpImportantMtxIdx[i] = mDrawMtxData.mDrawMtxIndex[i]; + wEvlpImportantMtxIdx[i] = getDrawMtxIndex(i); // For envelope matrices, we need to find the matrix with the most contribution. for (s32 i = 0; i < wEvlpMtxNum; i++) { @@ -100,26 +89,25 @@ void J3DJointTree::findImportantMtxIndex() { u16 bestIdx = 0; f32 bestWeight = -0.1f; - for (s32 j = 0; j < mixNum; j++) { + for (s32 j = 0; j < mixNum; j++, tableIdx++) { if (bestWeight < wEvlpMixWeight[tableIdx]) { bestWeight = wEvlpMixWeight[tableIdx]; bestIdx = wEvlpMixIndex[tableIdx]; } - - tableIdx++; } - wEvlpImportantMtxIdx[i + mDrawMtxData.mDrawFullWgtMtxNum] = bestIdx; + wEvlpImportantMtxIdx[i + getDrawFullWgtMtxNum()] = bestIdx; } } /* 80325CAC-80325D1C 3205EC 0070+00 1/0 0/0 0/0 .text * calc__12J3DJointTreeFP12J3DMtxBufferRC3VecRA3_A4_Cf */ void J3DJointTree::calc(J3DMtxBuffer* pMtxBuffer, Vec const& scale, f32 const (&mtx)[3][4]) { + J3D_ASSERT_NULLPTR(217, pMtxBuffer != NULL); getBasicMtxCalc()->init(scale, mtx); - J3DMtxCalc::setMtxBuffer(pMtxBuffer); - J3DJoint* root = getRootNode(); + getBasicMtxCalc()->setMtxBuffer(pMtxBuffer); + J3DJoint* root = getRootNode(); if (root == NULL) return; |
