Skip to content
Merged
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 configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def MatchingFor(*versions):
Object(MatchingFor("GZ2E01"), "JSystem/J3DGraphAnimator/J3DAnimation.cpp", extra_cflags=['-pragma "nosyminline off"']),
Object(MatchingFor("GZ2E01"), "JSystem/J3DGraphAnimator/J3DMaterialAnm.cpp"),
Object(NonMatching, "JSystem/J3DGraphAnimator/J3DSkinDeform.cpp"),
Object(NonMatching, "JSystem/J3DGraphAnimator/J3DCluster.cpp"),
Object(MatchingFor("GZ2E01"), "JSystem/J3DGraphAnimator/J3DCluster.cpp"),
Object(MatchingFor("GZ2E01"), "JSystem/J3DGraphAnimator/J3DJoint.cpp"),
Object(NonMatching, "JSystem/J3DGraphAnimator/J3DMaterialAttach.cpp"),
],
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/J3DGraphAnimator/J3DAnimation.h
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ class J3DAnmColor : public J3DAnmBase {
u16 getUpdateMaterialNum() const { return mUpdateMaterialNum; }
bool isValidUpdateMaterialID(u16 id) const { return mUpdateMaterialID[id] != 0xFFFF; }
u16 getUpdateMaterialID(u16 idx) const {
JUT_ASSERT_MSG(1578, 0 <= mUpdateMaterialNum - idx, "Error : range over.")
J3D_ASSERT(1578, idx < mUpdateMaterialNum, "Error : range over.")
return mUpdateMaterialID[idx];
}

Expand Down
6 changes: 5 additions & 1 deletion include/JSystem/J3DGraphAnimator/J3DCluster.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef J3DCLUSTER_H
#define J3DCLUSTER_H

#include "JSystem/JUtility/JUTAssert.h"
#include "dolphin/types.h"

class J3DDeformer;
Expand Down Expand Up @@ -79,7 +80,10 @@ class J3DDeformData {
/* 8032E274 */ void deform(J3DModel*);
/* 8032E364 */ void setAnm(J3DAnmCluster*);

J3DCluster* getClusterPointer(u16 index) { return &mClusterPointer[index]; }
J3DCluster* getClusterPointer(u16 index) {
J3D_ASSERT(186, (index < mClusterNum),"Error : range over.");
return &mClusterPointer[index];
}
u16 getClusterNum() const { return mClusterNum; }
u16 getClusterKeyNum() const { return mClusterKeyNum; }
J3DClusterKey* getClusterKeyPointer(u16 i) { return &mClusterKeyPointer[i]; }
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/J3DGraphAnimator/J3DJointTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class J3DJointTree {
J3DJoint* getRootNode() { return mRootNode; }
J3DJoint* getJointNodePointer(u16 idx) const { return mJointNodePointer[idx]; }
J3DMtxCalc* getBasicMtxCalc() const { return mBasicMtxCalc; }
Mtx& getInvJointMtx(s32 idx) const { return mInvJointMtx[idx]; }
Mtx& getInvJointMtx(int idx) { return mInvJointMtx[idx]; }
u32 getModelDataType() const { return mModelDataType; }
void setModelDataType(u32 type) { mModelDataType = type; }
bool checkFlag(u32 flag) { return mFlags & flag; }
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/J3DGraphAnimator/J3DModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class J3DModel {
Mtx& getBaseTRMtx() { return mBaseTransformMtx; }
void setBaseTRMtx(Mtx m) { MTXCopy(m, mBaseTransformMtx); }
u32 getMtxCalcMode() const { return mFlags & 0x03; }
J3DVertexBuffer* getVertexBuffer() const { return (J3DVertexBuffer*)&mVertexBuffer; }
J3DVertexBuffer* getVertexBuffer() { return (J3DVertexBuffer*)&mVertexBuffer; }
J3DMatPacket* getMatPacket(u16 idx) const { return &mMatPacket[idx]; }
J3DShapePacket* getShapePacket(u16 idx) const { return &mShapePacket[idx]; }
J3DMtxBuffer* getMtxBuffer() const { return mMtxBuffer; }
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/J3DGraphAnimator/J3DModelData.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class J3DModelData {
void setHierarchy(J3DModelHierarchy* hierarchy) { mJointTree.setHierarchy(hierarchy); }
void setBasicMtxCalc(J3DMtxCalc* calc) { mJointTree.setBasicMtxCalc(calc); }
JUTNameTab* getJointName() const { return mJointTree.getJointName(); }
Mtx& getInvJointMtx(s32 idx) const { return mJointTree.getInvJointMtx(idx); }
Mtx& getInvJointMtx(int idx) { return mJointTree.getInvJointMtx(idx); }
J3DTexture* getTexture() const { return mMaterialTable.getTexture(); }
JUTNameTab* getTextureName() const { return mMaterialTable.getTextureName(); }
u16 getWEvlpMtxNum() const { return mJointTree.getWEvlpMtxNum(); }
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/J3DGraphAnimator/J3DMtxBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class J3DMtxBuffer {

/* 80326214 */ void initialize();
/* 80326258 */ s32 create(J3DModelData*, u32);
/* 80326364 */ s32 createAnmMtx(J3DModelData*);
/* 80326364 */ J3DError createAnmMtx(J3DModelData*);
/* 803263F0 */ s32 createWeightEnvelopeMtx(J3DModelData*);
/* 8032648C */ s32 setNoUseDrawMtx();
/* 803264B8 */ s32 createDoubleDrawMtx(J3DModelData*, u32);
Expand Down
2 changes: 1 addition & 1 deletion include/JSystem/J3DGraphBase/J3DVertex.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class J3DVertexBuffer {

void* getTransformedVtxPos(int idx) { return mTransformedVtxPosArray[idx]; }
void* getTransformedVtxNrm(int idx) { return mTransformedVtxNrmArray[idx]; }
J3DVertexData* getVertexData() { return mVtxData; }
J3DVertexData* getVertexData() const { return mVtxData; }

void swapTransformedVtxPos() {
void* tmp = mTransformedVtxPosArray[0];
Expand Down
3 changes: 3 additions & 0 deletions include/JSystem/JUtility/JUTAssert.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#define JUT_ASSERT_MSG_F(LINE, COND, MSG, ...) \
(COND) ? (void)0 : (JUTAssertion::showAssert_f(JUTAssertion::getSDevice(), __FILE__, LINE, MSG, __VA_ARGS__), OSPanic(__FILE__, LINE, "Halt"));

#define J3D_ASSERT(LINE, COND, MSG) JUT_ASSERT_MSG(LINE, (COND) != 0, MSG)

#define JUT_PANIC(LINE, TEXT) \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, TEXT); \
OSPanic(__FILE__, LINE, "Halt");
Expand All @@ -33,6 +35,7 @@
#define JUT_ASSERT(...) (void)0;
#define JUT_ASSERT_MSG(...) (void)0;
#define JUT_ASSERT_MSG_F(...) (void)0;
#define J3D_ASSERT(...) (void)0;
#define JUT_PANIC(...)
#define JUT_WARN(...)
#define JUT_WARN_DEVICE(...)
Expand Down
94 changes: 46 additions & 48 deletions src/JSystem/J3DGraphAnimator/J3DCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@
#include "dolphin/base/PPCArch.h"
#include "dolphin/os.h"

#ifdef DEBUG
#define J3D_ASSERT(COND) \
if ((COND) == 0) { \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, __LINE__, \
"Error : null pointer"); \
OSPanic(__FILE__, __LINE__, "Halt"); \
}
#else
#define J3D_ASSERT(COND)
#endif

/* 8032E1F8-8032E230 328B38 0038+00 0/0 1/1 0/0 .text __ct__13J3DDeformDataFv */
J3DDeformData::J3DDeformData() {
mClusterNum = 0;
Expand All @@ -48,15 +37,15 @@ void J3DDeformData::offAllFlag(u32 i_flag) {
/* 8032E274-8032E298 328BB4 0024+00 0/0 1/1 0/0 .text deform__13J3DDeformDataFP8J3DModel
*/
void J3DDeformData::deform(J3DModel* model) {
J3D_ASSERT(model != NULL);
J3D_ASSERT(110, model,"Error : null pointer");

deform(model->getVertexBuffer());
}

/* 8032E298-8032E364 328BD8 00CC+00 1/1 0/0 0/0 .text deform__13J3DDeformDataFP15J3DVertexBuffer
*/
void J3DDeformData::deform(J3DVertexBuffer* buffer) {
J3D_ASSERT(buffer != NULL);
J3D_ASSERT(141, buffer,"Error : null pointer");

buffer->swapVtxPosArrayPointer();
buffer->swapVtxNrmArrayPointer();
Expand Down Expand Up @@ -94,7 +83,7 @@ J3DDeformer::J3DDeformer(J3DDeformData* data) {
/* 8032E3BC-8032E4A4 328CFC 00E8+00 1/1 0/0 0/0 .text deform__11J3DDeformerFP15J3DVertexBufferUs
*/
void J3DDeformer::deform(J3DVertexBuffer* buffer, u16 param_1) {
J3D_ASSERT(buffer != 0);
J3D_ASSERT(222, buffer,"Error : null pointer");

u16 var_r31 = 0;
if (mAnmCluster != NULL) {
Expand All @@ -115,6 +104,7 @@ void J3DDeformer::deform(J3DVertexBuffer* buffer, u16 param_1) {
* deform_VtxPosF32__11J3DDeformerFP15J3DVertexBufferP10J3DClusterP13J3DClusterKeyPf */
void J3DDeformer::deform_VtxPosF32(J3DVertexBuffer* i_buffer, J3DCluster* i_cluster,
J3DClusterKey* i_key, f32* i_weights) {
J3DClusterKey* key;
int posNum = i_cluster->mPosNum;
int keyNum = i_cluster->mKeyNum;
f32* vtxPosArray = (f32*)i_buffer->getVtxPosArrayPointer(0);
Expand All @@ -129,18 +119,22 @@ void J3DDeformer::deform_VtxPosF32(J3DVertexBuffer* i_buffer, J3DCluster* i_clus
}

f32 local_58[2] = {1.0f, -1.0f};

for (u16 i = 0; i < posNum; i++) {
int index = i_cluster->field_0x18[i] * 3;
for (u16 j = 0; j < keyNum; j++) {
int uVar7 = ((u16*)i_key[j].field_0x4)[i];
f32* deform = &deformVtxPos[(uVar7 & ~0xE000) * 3];
f32 deform0 = deform[0];
f32 deform1 = deform[1];
f32 deform2 = deform[2];
deform0 *= local_58[((uVar7 & 0x8000) >> 0xF)];
deform1 *= local_58[((uVar7 & 0x4000) >> 0xE)];
deform2 *= local_58[((uVar7 & 0x2000) >> 0xD)];
int uVar8;
int uVar7;
key = &i_key[j];
uVar8 = uVar7 = ((u16*)key->field_0x4)[i];
uVar7 &= ~0xE000;
uVar7 *= 3;
f32 deform0 = deformVtxPos[uVar7];
f32 deform1 = deformVtxPos[uVar7 + 1];
f32 deform2 = deformVtxPos[uVar7 + 2];
deform0 *= local_58[((uVar8 & 0x8000) >> 0xF)];
deform1 *= local_58[((uVar8 & 0x4000) >> 0xE)];
deform2 *= local_58[((uVar8 & 0x2000) >> 0xD)];
vtxPosArray[index] += deform0 * i_weights[j];
vtxPosArray[index + 1] += deform1 * i_weights[j];
vtxPosArray[index + 2] += deform2 * i_weights[j];
Expand All @@ -165,26 +159,30 @@ void J3DDeformer::deform_VtxNrmF32(J3DVertexBuffer* i_buffer, J3DCluster* i_clus
iVar13[index + 1] = 0.0f;
iVar13[index + 2] = 0.0f;
for (u16 j = 0; j < keyNum; j++) {
int uVar3 = ((u16*)i_key[j].field_0x8)[i];
f32 deform0, deform1, deform2;
if (uVar3 & 0x8000) {
deform0 = -deformVtxNrm[(uVar3 & ~0xE000) * 3];
J3DClusterKey* key = &i_key[j];
int uVar3 = ((u16*)key->field_0x8)[i];
int uVar4 = uVar3;
uVar3 &= ~0xE000;
uVar3 *= 3;
Vec deform0;
if (uVar4 & 0x8000) {
deform0.x = -deformVtxNrm[uVar3];
} else {
deform0 = deformVtxNrm[(uVar3 & ~0xE000) * 3];
deform0.x = deformVtxNrm[uVar3];
}
if (uVar3 & 0x4000) {
deform1 = -deformVtxNrm[(uVar3 & ~0xE000) * 3 + 1];
if (uVar4 & 0x4000) {
deform0.y = -deformVtxNrm[uVar3 + 1];
} else {
deform1 = deformVtxNrm[(uVar3 & ~0xE000) * 3 + 1];
deform0.y = deformVtxNrm[uVar3 + 1];
}
if (uVar3 & 0x2000) {
deform2 = -deformVtxNrm[(uVar3 & ~0xE000) * 3 + 2];
if (uVar4 & 0x2000) {
deform0.z = -deformVtxNrm[uVar3 + 2];
} else {
deform2 = deformVtxNrm[(uVar3 & ~0xE000) * 3 + 2];
deform0.z = deformVtxNrm[uVar3 + 2];
}
iVar13[index] += deform0 * i_weights[j];
iVar13[index + 1] += deform1 * i_weights[j];
iVar13[index + 2] += deform2 * i_weights[j];
iVar13[index] += deform0.x * i_weights[j];
iVar13[index + 1] += deform0.y * i_weights[j];
iVar13[index + 2] += deform0.z * i_weights[j];
}
normalize(&iVar13[index]);
}
Expand All @@ -210,7 +208,8 @@ void J3DDeformer::deform_VtxNrmF32(J3DVertexBuffer* i_buffer, J3DCluster* i_clus
continue;
}
int index = tmp * 3;
int index2 = clusterVtx->field_0x4[j] * 3;
u16 iVar4 = clusterVtx->field_0x4[j];
int index2 = iVar4 * 3;

f32 dot = vec.x * iVar13[index2] + vec.y * iVar13[index2 + 1]
+ vec.z * iVar13[index2 + 2];
Expand All @@ -228,18 +227,17 @@ void J3DDeformer::deform_VtxNrmF32(J3DVertexBuffer* i_buffer, J3DCluster* i_clus
vtxNrmArray[index + 1] = vec.y;
vtxNrmArray[index + 2] = vec.z;
} else if (angle > i_cluster->mMaxAngle) {
int index3 = clusterVtx->field_0x4[j];
Vec* iVar13a = (Vec*)iVar13;
vtxNrmArray[index] = iVar13a[index3].x;
vtxNrmArray[index + 1] = iVar13a[index3].y;
vtxNrmArray[index + 2] = iVar13a[index3].z;
vtxNrmArray[index] = iVar13[iVar4 * 3];
vtxNrmArray[index + 1] = iVar13[iVar4 * 3 + 1];
vtxNrmArray[index + 2] = iVar13[iVar4 * 3 + 2];
} else {
f32 weight1 = (angle - i_cluster->mMinAngle)
f32 weights[2];
weights[0] = (angle - i_cluster->mMinAngle)
/ (i_cluster->mMaxAngle - i_cluster->mMinAngle);
f32 weight2 = 1.0f - weight1;
vtxNrmArray[index] = weight1 * iVar13[index2] + weight2 * vec.x;
vtxNrmArray[index + 1] = weight1 * iVar13[index2 + 1] + weight2 * vec.y;
vtxNrmArray[index + 2] = weight1 * iVar13[index2 + 2] + weight2 * vec.z;
weights[1] = 1.0f - weights[0];
vtxNrmArray[index] = weights[0] * iVar13[index2] + weights[1] * vec.x;
vtxNrmArray[index + 1] = weights[0] * iVar13[index2 + 1] + weights[1] * vec.y;
vtxNrmArray[index + 2] = weights[0] * iVar13[index2 + 2] + weights[1] * vec.z;
}
}
}
Expand Down
Loading