mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-08-18 04:48:21 -04:00
J3D debug (#3037)
* J3DGraphBase debug * J3DGraphAnimator debug * J3DGraphLoader debug
This commit is contained in:
@@ -565,9 +565,8 @@ f32 J3DGetKeyFrameInterpolation(f32 frame, J3DAnmKeyTableBase* pKeyTable, T* pDa
|
||||
}
|
||||
|
||||
if (pKeyTable->mType == 0) {
|
||||
u32 idx = pKeyTable->mMaxFrame - 1;
|
||||
if (pData[idx * 3] <= frame) {
|
||||
return pData[idx * 3 + 1];
|
||||
if (pData[(pKeyTable->mMaxFrame - 1) * 3] <= frame) {
|
||||
return pData[(pKeyTable->mMaxFrame - 1) * 3 + 1];
|
||||
}
|
||||
|
||||
u32 uVar7 = pKeyTable->mMaxFrame;
|
||||
@@ -585,9 +584,8 @@ f32 J3DGetKeyFrameInterpolation(f32 frame, J3DAnmKeyTableBase* pKeyTable, T* pDa
|
||||
f32 interpolated = J3DHermiteInterpolation(frame, &pData[0], &pData[1], &pData[2], &pData[3], &pData[4], &pData[5]);
|
||||
return interpolated;
|
||||
} else {
|
||||
u32 idx = pKeyTable->mMaxFrame - 1;
|
||||
if (pData[idx * 4] <= frame) {
|
||||
return pData[idx * 4 + 1];
|
||||
if (pData[(pKeyTable->mMaxFrame - 1) * 4] <= frame) {
|
||||
return pData[(pKeyTable->mMaxFrame - 1) * 4 + 1];
|
||||
}
|
||||
|
||||
u32 var_r27 = pKeyTable->mMaxFrame;
|
||||
|
||||
@@ -252,6 +252,10 @@ void J3DDeformer::deform(J3DVertexBuffer* i_buffer, u16 param_1, f32* i_weights)
|
||||
}
|
||||
}
|
||||
|
||||
static void dummy(J3DDeformData* data) {
|
||||
data->getClusterNum();
|
||||
}
|
||||
|
||||
void J3DDeformer::normalizeWeight(int i_keyNum, f32* i_weights) {
|
||||
f32 totalWeight = 0.0f;
|
||||
for (u16 i = 0; i < i_keyNum; i++) {
|
||||
|
||||
@@ -10,16 +10,16 @@
|
||||
|
||||
void J3DMtxCalcJ3DSysInitBasic::init(Vec const& scale, Mtx const& mtx) {
|
||||
J3DSys::mCurrentS = scale;
|
||||
J3DSys::mParentS = (Vec){1.0f, 1.0f, 1.0f};
|
||||
JMAMTXApplyScale(mtx, J3DSys::mCurrentMtx, J3DSys::mCurrentS.x, J3DSys::mCurrentS.y,
|
||||
J3DSys::mCurrentS.z);
|
||||
Vec init = {1.0f, 1.0f, 1.0f};
|
||||
J3DSys::mParentS = init;
|
||||
JMAMTXApplyScale(mtx, J3DSys::mCurrentMtx, scale.x, scale.y, scale.z);
|
||||
}
|
||||
|
||||
void J3DMtxCalcJ3DSysInitMaya::init(Vec const& scale, Mtx const& mtx) {
|
||||
J3DSys::mParentS = (Vec){1.0f, 1.0f, 1.0f};
|
||||
Vec init = {1.0f, 1.0f, 1.0f};
|
||||
J3DSys::mParentS = init;
|
||||
J3DSys::mCurrentS = scale;
|
||||
JMAMTXApplyScale(mtx, J3DSys::mCurrentMtx, J3DSys::mCurrentS.x, J3DSys::mCurrentS.y,
|
||||
J3DSys::mCurrentS.z);
|
||||
JMAMTXApplyScale(mtx, J3DSys::mCurrentMtx, scale.x, scale.y, scale.z);
|
||||
}
|
||||
|
||||
J3DMtxBuffer* J3DMtxCalc::mMtxBuffer;
|
||||
@@ -35,8 +35,9 @@ inline s32 checkScaleOne(const Vec& param_0) {
|
||||
}
|
||||
|
||||
void J3DMtxCalcCalcTransformBasic::calcTransform(J3DTransformInfo const& transInfo) {
|
||||
J3DJoint* joint = J3DMtxCalc::getJoint();
|
||||
J3DMtxBuffer* mtxBuf = J3DMtxCalc::getMtxBuffer();
|
||||
u16 jntNo = J3DMtxCalc::getJoint()->getJntNo();
|
||||
u16 jntNo = joint->getJntNo();
|
||||
|
||||
MtxP anmMtx = mtxBuf->getAnmMtx(jntNo);
|
||||
|
||||
@@ -58,8 +59,9 @@ void J3DMtxCalcCalcTransformBasic::calcTransform(J3DTransformInfo const& transIn
|
||||
}
|
||||
|
||||
void J3DMtxCalcCalcTransformSoftimage::calcTransform(J3DTransformInfo const& transInfo) {
|
||||
J3DJoint* joint = J3DMtxCalc::getJoint();
|
||||
J3DMtxBuffer* mtxBuf = J3DMtxCalc::getMtxBuffer();
|
||||
u16 jntNo = J3DMtxCalc::getJoint()->getJntNo();
|
||||
u16 jntNo = joint->getJntNo();
|
||||
|
||||
MtxP anmMtx = mtxBuf->getAnmMtx(jntNo);
|
||||
|
||||
@@ -104,20 +106,22 @@ void J3DMtxCalcCalcTransformMaya::calcTransform(J3DTransformInfo const& transInf
|
||||
transInfo.mScale.z);
|
||||
}
|
||||
|
||||
if (joint->getScaleCompensate() == 1) {
|
||||
f32 invX = JMath::fastReciprocal(J3DSys::mParentS.x);
|
||||
f32 invY = JMath::fastReciprocal(J3DSys::mParentS.y);
|
||||
f32 invZ = JMath::fastReciprocal(J3DSys::mParentS.z);
|
||||
u8 scaleCompensate = joint->getScaleCompensate();
|
||||
if (scaleCompensate == 1) {
|
||||
Vec inv;
|
||||
inv.x = JMath::fastReciprocal(J3DSys::mParentS.x);
|
||||
inv.y = JMath::fastReciprocal(J3DSys::mParentS.y);
|
||||
inv.z = JMath::fastReciprocal(J3DSys::mParentS.z);
|
||||
|
||||
anmMtx[0][0] *= invX;
|
||||
anmMtx[0][1] *= invX;
|
||||
anmMtx[0][2] *= invX;
|
||||
anmMtx[1][0] *= invY;
|
||||
anmMtx[1][1] *= invY;
|
||||
anmMtx[1][2] *= invY;
|
||||
anmMtx[2][0] *= invZ;
|
||||
anmMtx[2][1] *= invZ;
|
||||
anmMtx[2][2] *= invZ;
|
||||
anmMtx[0][0] *= inv.x;
|
||||
anmMtx[0][1] *= inv.x;
|
||||
anmMtx[0][2] *= inv.x;
|
||||
anmMtx[1][0] *= inv.y;
|
||||
anmMtx[1][1] *= inv.y;
|
||||
anmMtx[1][2] *= inv.y;
|
||||
anmMtx[2][0] *= inv.z;
|
||||
anmMtx[2][1] *= inv.z;
|
||||
anmMtx[2][2] *= inv.z;
|
||||
}
|
||||
|
||||
MTXConcat(J3DSys::mCurrentMtx, anmMtx, J3DSys::mCurrentMtx);
|
||||
@@ -131,13 +135,13 @@ void J3DMtxCalcCalcTransformMaya::calcTransform(J3DTransformInfo const& transInf
|
||||
void J3DJoint::appendChild(J3DJoint* pChild) {
|
||||
if (mChild == NULL) {
|
||||
mChild = pChild;
|
||||
} else {
|
||||
J3DJoint* curChild = mChild;
|
||||
while (curChild->getYounger() != NULL) {
|
||||
curChild = curChild->getYounger();
|
||||
}
|
||||
curChild->setYounger(pChild);
|
||||
return;
|
||||
}
|
||||
J3DJoint* curChild = mChild;
|
||||
while (curChild->getYounger() != NULL) {
|
||||
curChild = curChild->getYounger();
|
||||
}
|
||||
curChild->setYounger(pChild);
|
||||
}
|
||||
|
||||
J3DJoint::J3DJoint() {
|
||||
@@ -149,7 +153,8 @@ J3DJoint::J3DJoint() {
|
||||
mJntNo = 0;
|
||||
mKind = 1;
|
||||
mScaleCompensate = false;
|
||||
__memcpy(&mTransformInfo, &j3dDefaultTransformInfo, sizeof(J3DTransformInfo));
|
||||
J3DTransformInfo* r30 = &mTransformInfo;
|
||||
void* r29 = __memcpy(r30, &j3dDefaultTransformInfo, sizeof(J3DTransformInfo));
|
||||
mBoundingSphereRadius = 0.0f;
|
||||
mMtxCalc = NULL;
|
||||
mMesh = NULL;
|
||||
@@ -173,16 +178,16 @@ void J3DJoint::entryIn() {
|
||||
j3dSys.getModel()->getShapePacket(mesh->getShape()->getIndex());
|
||||
if (!matPacket->isLocked()) {
|
||||
if (mesh->getMaterialAnm()) {
|
||||
J3DMaterialAnm* piVar8 = mesh->getMaterialAnm();
|
||||
piVar8->calc(mesh);
|
||||
mesh->getMaterialAnm()->calc(mesh);
|
||||
}
|
||||
mesh->calc(anmMtx);
|
||||
}
|
||||
mesh->setCurrentMtx();
|
||||
matPacket->setMaterialAnmID(mesh->getMaterialAnm());
|
||||
matPacket->setShapePacket(shapePacket);
|
||||
J3DDrawBuffer* drawBuffer = j3dSys.getDrawBuffer(mesh->isDrawModeOpaTexEdge());
|
||||
if ((u8)matPacket->entry(drawBuffer)) {
|
||||
bool isDrawModeOpaTexEdge = mesh->isDrawModeOpaTexEdge() == FALSE;
|
||||
u8 r24 = matPacket->entry(j3dSys.getDrawBuffer(isDrawModeOpaTexEdge));
|
||||
if (r24) {
|
||||
j3dSys.setMatPacket(matPacket);
|
||||
J3DDrawBuffer::entryNum++;
|
||||
mesh->makeDisplayList();
|
||||
@@ -197,18 +202,18 @@ J3DMtxCalc* J3DJoint::mCurrentMtxCalc;
|
||||
void J3DJoint::recursiveCalc() {
|
||||
J3DMtxCalc* prevMtxCalc = NULL;
|
||||
Mtx prevCurrentMtx;
|
||||
mDoMtx_copy(J3DSys::mCurrentMtx, prevCurrentMtx);
|
||||
f32 currentX = J3DSys::mCurrentS.x;
|
||||
f32 currentY = J3DSys::mCurrentS.y;
|
||||
f32 currentZ = J3DSys::mCurrentS.z;
|
||||
f32 parentX = J3DSys::mParentS.x;
|
||||
f32 parentY = J3DSys::mParentS.y;
|
||||
f32 parentZ = J3DSys::mParentS.z;
|
||||
MTXCopy(J3DSys::mCurrentMtx, prevCurrentMtx);
|
||||
Vec current, parent;
|
||||
current = J3DSys::mCurrentS;
|
||||
parent = J3DSys::mParentS;
|
||||
if (getMtxCalc() != NULL) {
|
||||
prevMtxCalc = getCurrentMtxCalc();
|
||||
J3DMtxCalc* piVar2 = this->getMtxCalc();
|
||||
setCurrentMtxCalc(piVar2);
|
||||
J3DMtxCalc::setJoint(this);
|
||||
#if DEBUG
|
||||
J3DMtxCalc::setMtxBuffer(J3DMtxCalc::getMtxBuffer());
|
||||
#endif
|
||||
piVar2->calc();
|
||||
} else {
|
||||
if (getCurrentMtxCalc() != NULL) {
|
||||
@@ -223,18 +228,14 @@ void J3DJoint::recursiveCalc() {
|
||||
(*jointCallback)(this, 0);
|
||||
}
|
||||
|
||||
J3DJoint* child = getChild();
|
||||
if (child != NULL) {
|
||||
child->recursiveCalc();
|
||||
J3DJoint* joint = getChild();
|
||||
if (joint != NULL) {
|
||||
joint->recursiveCalc();
|
||||
}
|
||||
mDoMtx_copy(prevCurrentMtx, J3DSys::mCurrentMtx);
|
||||
MTXCopy(prevCurrentMtx, J3DSys::mCurrentMtx);
|
||||
|
||||
J3DSys::mCurrentS.x = currentX;
|
||||
J3DSys::mCurrentS.y = currentY;
|
||||
J3DSys::mCurrentS.z = currentZ;
|
||||
J3DSys::mParentS.x = parentX;
|
||||
J3DSys::mParentS.y = parentY;
|
||||
J3DSys::mParentS.z = parentZ;
|
||||
J3DSys::mCurrentS = current;
|
||||
J3DSys::mParentS = parent;
|
||||
|
||||
if (prevMtxCalc != NULL) {
|
||||
setCurrentMtxCalc(prevMtxCalc);
|
||||
@@ -243,8 +244,8 @@ void J3DJoint::recursiveCalc() {
|
||||
(*jointCallback)(this, 1);
|
||||
}
|
||||
|
||||
J3DJoint* younger = getYounger();
|
||||
if (younger != NULL) {
|
||||
younger->recursiveCalc();
|
||||
joint = getYounger();
|
||||
if (joint != NULL) {
|
||||
joint->recursiveCalc();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,8 +148,8 @@ s32 J3DModel::createMatPacket(J3DModelData* pModelData, u32 mdlFlags) {
|
||||
} else {
|
||||
if (pModelData->getModelDataType() == 1) {
|
||||
if (mdlFlags & J3DMdlFlag_UseSingleDL) {
|
||||
matPacket->mpDisplayListObj = materialNode->getSharedDisplayListObj();
|
||||
matPacket->setDisplayListObj(matPacket->mpDisplayListObj);
|
||||
J3DDisplayListObj* dlobj = materialNode->getSharedDisplayListObj();
|
||||
matPacket->setDisplayListObj(dlobj);
|
||||
} else {
|
||||
J3DDisplayListObj* dlobj = materialNode->getSharedDisplayListObj();
|
||||
ret = dlobj->single_To_Double();
|
||||
|
||||
@@ -409,7 +409,10 @@ void J3DMtxBuffer::calcDrawMtx(u32 mdlFlag, Vec const& param_1, Mtx const& param
|
||||
|
||||
MtxP viewMtx;
|
||||
Mtx viewBaseMtx;
|
||||
u16 fullWgtNum;
|
||||
u16 fullWgtNum; // r25
|
||||
u16 local_68;
|
||||
u16 local_6a;
|
||||
u16 local_6c;
|
||||
|
||||
switch (mdlFlag) {
|
||||
case 0:
|
||||
@@ -424,19 +427,19 @@ void J3DMtxBuffer::calcDrawMtx(u32 mdlFlag, Vec const& param_1, Mtx const& param
|
||||
}
|
||||
return;
|
||||
case 1:
|
||||
fullWgtNum = mJointTree->getDrawFullWgtMtxNum();
|
||||
for (u16 i = 0; i < fullWgtNum; i++) {
|
||||
local_68 = mJointTree->getDrawFullWgtMtxNum();
|
||||
for (u16 i = 0; i < local_68; i++) {
|
||||
MTXCopy(getAnmMtx(mJointTree->getDrawMtxIndex(i)), *getDrawMtx(i));
|
||||
}
|
||||
fullWgtNum = mJointTree->getDrawFullWgtMtxNum();
|
||||
for (u16 i = 0; i < fullWgtNum; i++) {
|
||||
local_6a = mJointTree->getDrawFullWgtMtxNum();
|
||||
for (u16 i = 0; i < local_6a; i++) {
|
||||
MTXCopy(getWeightAnmMtx(i), *getDrawMtx(mJointTree->getDrawFullWgtMtxNum() + i));
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
J3DCalcViewBaseMtx(j3dSys.getViewMtx(), param_1, param_2, viewBaseMtx);
|
||||
fullWgtNum = mJointTree->getDrawFullWgtMtxNum();
|
||||
for (u16 i = 0; i < fullWgtNum; i++) {
|
||||
local_6c = mJointTree->getDrawFullWgtMtxNum();
|
||||
for (u16 i = 0; i < local_6c; i++) {
|
||||
MTXConcat(viewBaseMtx, getAnmMtx(mJointTree->getDrawMtxIndex(i)), *getDrawMtx(i));
|
||||
}
|
||||
if (mJointTree->getDrawMtxNum() > mJointTree->getDrawFullWgtMtxNum()) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "JSystem/JSystem.h" // IWYU pragma: keep
|
||||
|
||||
#include "JSystem/J3DGraphAnimator/J3DSkinDeform.h"
|
||||
#include "JSystem/J3DGraphAnimator/J3DAnimation.h"
|
||||
#include "JSystem/J3DGraphAnimator/J3DModel.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include <string>
|
||||
@@ -675,4 +676,23 @@ void J3DVtxColorCalc::calc(J3DModel* pModel) {
|
||||
calc(pModel->getVertexBuffer());
|
||||
}
|
||||
|
||||
void J3DVtxColorCalc::calc(J3DVertexBuffer* buffer) {
|
||||
J3D_ASSERT_NULLPTR(1366, buffer != NULL);
|
||||
if (checkFlag(1) && mpVtxColor) {
|
||||
buffer->swapVtxColArrayPointer();
|
||||
u16 anmTableNum = mpVtxColor->getAnmTableNum(0);
|
||||
GXColor* colorArray = buffer->getVtxColArrayPointer(0);
|
||||
for (u32 i = 0; i < anmTableNum; i++) {
|
||||
GXColor color;
|
||||
mpVtxColor->getColor(0, i, &color);
|
||||
J3DAnmVtxColorIndexData* r28 = mpVtxColor->getAnmVtxColorIndexData(0, i);
|
||||
for (u32 j = 0; j < r28->mNum; j++) {
|
||||
colorArray[((u16*)r28->mpData)[j]] = color;
|
||||
}
|
||||
}
|
||||
DCStoreRange(colorArray, buffer->getVertexData()->getColNum() * 4);
|
||||
buffer->setCurrentVtxCol(colorArray);
|
||||
}
|
||||
}
|
||||
|
||||
J3DSkinDeform::~J3DSkinDeform() {}
|
||||
|
||||
Reference in New Issue
Block a user