summaryrefslogtreecommitdiff
path: root/src/JSystem/J3DGraphBase
diff options
context:
space:
mode:
Diffstat (limited to 'src/JSystem/J3DGraphBase')
-rw-r--r--src/JSystem/J3DGraphBase/J3DShape.cpp9
-rw-r--r--src/JSystem/J3DGraphBase/J3DShapeMtx.cpp17
-rw-r--r--src/JSystem/J3DGraphBase/J3DStruct.cpp120
-rw-r--r--src/JSystem/J3DGraphBase/J3DSys.cpp2
-rw-r--r--src/JSystem/J3DGraphBase/J3DTevs.cpp4
-rw-r--r--src/JSystem/J3DGraphBase/J3DTransform.cpp12
-rw-r--r--src/JSystem/J3DGraphBase/J3DVertex.cpp4
7 files changed, 144 insertions, 24 deletions
diff --git a/src/JSystem/J3DGraphBase/J3DShape.cpp b/src/JSystem/J3DGraphBase/J3DShape.cpp
index 1c7500fac4..91dd5b8ea0 100644
--- a/src/JSystem/J3DGraphBase/J3DShape.cpp
+++ b/src/JSystem/J3DGraphBase/J3DShape.cpp
@@ -72,9 +72,11 @@ void J3DShape::addTexMtxIndexInVcd(GXAttr attr) {
GXVtxDescList* vtxDesc = getVtxDesc();
s32 attrCount = 0;
- for (; vtxDesc->attr != GX_VA_NULL; attrCount++, vtxDesc++) {
- if (vtxDesc->attr == GX_VA_PNMTXIDX)
+ for (; vtxDesc->attr != GX_VA_NULL; vtxDesc++) {
+ if (vtxDesc->attr == GX_VA_PNMTXIDX) {
attrIdx = stride;
+ }
+ attrCount++;
}
if (attrIdx == -1)
@@ -85,7 +87,7 @@ void J3DShape::addTexMtxIndexInVcd(GXAttr attr) {
vtxDesc = getVtxDesc();
GXVtxDescList* dst = newVtxDesc;
- for (; vtxDesc->attr != GX_VA_NULL; dst++, vtxDesc++) {
+ for (; vtxDesc->attr != GX_VA_NULL; vtxDesc++) {
if ((attr < vtxDesc->attr) && !inserted) {
dst->attr = attr;
dst->type = GX_DIRECT;
@@ -98,6 +100,7 @@ void J3DShape::addTexMtxIndexInVcd(GXAttr attr) {
dst->attr = vtxDesc->attr;
dst->type = vtxDesc->type;
stride = stride + kSize[vtxDesc->type];
+ dst++;
}
dst->attr = GX_VA_NULL;
diff --git a/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp b/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp
index a7a4918ddf..a48f9ab928 100644
--- a/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp
+++ b/src/JSystem/J3DGraphBase/J3DShapeMtx.cpp
@@ -271,9 +271,7 @@ void J3DDifferedTexMtx::loadExecute(f32 const (*param_0)[4]) {
MTXInverse(j3dSys.getViewMtx(), sp_a8);
MTXConcat(sp_e8, sp_a8, sp_e8);
MTXConcat(sp_e8, param_0, sp_e8);
- sp_e8[2][3] = 0.0f;
- sp_e8[1][3] = 0.0f;
- sp_e8[0][3] = 0.0f;
+ sp_e8[0][3] = sp_e8[1][3] = sp_e8[2][3] = 0.0f;
mtx = &sp_e8;
break;
}
@@ -415,6 +413,11 @@ void J3DShapeMtxMulti::calcNBTScale(Vec const& param_0, Mtx33* param_1, Mtx33* p
}
void J3DShapeMtxMultiConcatView::load() const {
+ static u8 mtxCache[20] = {
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+ };
+
sMtxPtrTbl[0] = j3dSys.getModel()->getMtxBuffer()->getUserAnmMtx(0);
sMtxPtrTbl[1] = j3dSys.getModel()->getWeightAnmMtx(0);
@@ -434,8 +437,7 @@ void J3DShapeMtxMultiConcatView::load() const {
int use_mtx_num = mUseMtxNum;
for (int i = 0; i < use_mtx_num; i++) {
- u32 current_pipeline = sCurrentPipeline;
- J3DShapeMtxConcatView_LoadFunc func = sMtxLoadLODPipeline[current_pipeline];
+ J3DShapeMtxConcatView_LoadFunc func = sMtxLoadLODPipeline[sCurrentPipeline];
if (mUseMtxIndexTable[i] != 0xffff) {
u16 important_mtx_index = important_mtx_indices[mUseMtxIndexTable[i]];
@@ -546,8 +548,5 @@ void J3DShapeMtxYBBoardConcatView::load() const {
}
static void dummy() {
- static u8 mtxCache[20] = {
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
- };
+
}
diff --git a/src/JSystem/J3DGraphBase/J3DStruct.cpp b/src/JSystem/J3DGraphBase/J3DStruct.cpp
index bc455e62c1..b273cafffe 100644
--- a/src/JSystem/J3DGraphBase/J3DStruct.cpp
+++ b/src/JSystem/J3DGraphBase/J3DStruct.cpp
@@ -7,6 +7,41 @@
#include "JSystem/J3DGraphBase/J3DStruct.h"
#include "JSystem/JMath/JMath.h"
+bool J3DTextureSRTInfo::operator==(J3DTextureSRTInfo& other) const {
+ if (mScaleX == other.mScaleX &&
+ mScaleY == other.mScaleY &&
+ mRotation == other.mRotation &&
+ mTranslationX == other.mTranslationX &&
+ mTranslationY == other.mTranslationY
+ ) {
+ return true;
+ }
+ return false;
+}
+
+bool J3DLightInfo::operator==(J3DLightInfo& other) const {
+ if (mLightPosition.x == other.mLightPosition.x &&
+ mLightPosition.y == other.mLightPosition.y &&
+ mLightPosition.z == other.mLightPosition.z &&
+ mLightDirection.x == other.mLightDirection.x &&
+ mLightDirection.y == other.mLightDirection.y &&
+ mLightDirection.z == other.mLightDirection.z &&
+ mColor.r == other.mColor.r &&
+ mColor.g == other.mColor.g &&
+ mColor.b == other.mColor.b &&
+ mColor.a == other.mColor.a &&
+ mCosAtten.x == other.mCosAtten.x &&
+ mCosAtten.y == other.mCosAtten.y &&
+ mCosAtten.z == other.mCosAtten.z &&
+ mDistAtten.x == other.mDistAtten.x &&
+ mDistAtten.y == other.mDistAtten.y &&
+ mDistAtten.z == other.mDistAtten.z
+ ) {
+ return true;
+ }
+ return false;
+}
+
J3DLightInfo& J3DLightInfo::operator=(J3DLightInfo const& param_0) {
JMath::gekko_ps_copy6(&mLightPosition, &param_0.mLightPosition);
mColor = param_0.mColor;
@@ -14,6 +49,42 @@ J3DLightInfo& J3DLightInfo::operator=(J3DLightInfo const& param_0) {
return *this;
}
+bool J3DTexMtxInfo::operator==(J3DTexMtxInfo& other) const {
+ if (mProjection != other.mProjection ||
+ mInfo != other.mInfo ||
+ !(mSRT == other.mSRT)
+ ) {
+ return false;
+ }
+ if (mEffectMtx[0][0] != other.mEffectMtx[0][0] ||
+ mEffectMtx[0][1] != other.mEffectMtx[0][1] ||
+ mEffectMtx[0][2] != other.mEffectMtx[0][2] ||
+ mEffectMtx[0][3] != other.mEffectMtx[0][3] ||
+ mEffectMtx[1][0] != other.mEffectMtx[1][0] ||
+ mEffectMtx[1][1] != other.mEffectMtx[1][1] ||
+ mEffectMtx[1][2] != other.mEffectMtx[1][2] ||
+ mEffectMtx[1][3] != other.mEffectMtx[1][3] ||
+ mEffectMtx[2][0] != other.mEffectMtx[2][0] ||
+ mEffectMtx[2][1] != other.mEffectMtx[2][1] ||
+ mEffectMtx[2][2] != other.mEffectMtx[2][2] ||
+ mEffectMtx[2][3] != other.mEffectMtx[2][3] ||
+ mEffectMtx[3][0] != other.mEffectMtx[3][0] ||
+ mEffectMtx[3][1] != other.mEffectMtx[3][1] ||
+ mEffectMtx[3][2] != other.mEffectMtx[3][2] ||
+ mEffectMtx[3][3] != other.mEffectMtx[3][3]
+ ) {
+ return false;
+ }
+ if (
+ mCenter.x != other.mCenter.x ||
+ mCenter.y != other.mCenter.y ||
+ mCenter.z != other.mCenter.z
+ ) {
+ return false;
+ }
+ return true;
+}
+
J3DTexMtxInfo& J3DTexMtxInfo::operator=(J3DTexMtxInfo const& param_0) {
mProjection = param_0.mProjection;
mInfo = param_0.mInfo;
@@ -47,7 +118,30 @@ J3DIndTexMtxInfo& J3DIndTexMtxInfo::operator=(J3DIndTexMtxInfo const& param_0) {
return *this;
}
-J3DFogInfo& J3DFogInfo::operator=(J3DFogInfo const& param_0) {
+bool J3DFogInfo::operator==(J3DFogInfo& other) const {
+ if (mType == other.mType &&
+ mAdjEnable == other.mAdjEnable &&
+ mCenter == other.mCenter &&
+ mStartZ == other.mStartZ &&
+ mEndZ == other.mEndZ &&
+ mNearZ == other.mNearZ &&
+ mFarZ == other.mFarZ &&
+ mColor.r == other.mColor.r &&
+ mColor.g == other.mColor.g &&
+ mColor.b == other.mColor.b &&
+ mColor.a == other.mColor.a
+ ) {
+ for (int i = 0; i < 10; i++) {
+ if (mFogAdjTable.r[i] != other.mFogAdjTable.r[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+J3DFogInfo& J3DFogInfo::operator=(const J3DFogInfo& param_0) {
mType = param_0.mType;
mAdjEnable = param_0.mAdjEnable;
mCenter = param_0.mCenter;
@@ -55,15 +149,31 @@ J3DFogInfo& J3DFogInfo::operator=(J3DFogInfo const& param_0) {
mEndZ = param_0.mEndZ;
mNearZ = param_0.mNearZ;
mFarZ = param_0.mFarZ;
- mColor = param_0.mColor;
+ mColor.r = param_0.mColor.r;
+ mColor.g = param_0.mColor.g;
+ mColor.b = param_0.mColor.b;
+ mColor.a = param_0.mColor.a;
for (int i = 0; i < 10; i++) {
mFogAdjTable.r[i] = param_0.mFogAdjTable.r[i];
}
return *this;
}
-J3DNBTScaleInfo& J3DNBTScaleInfo::operator=(J3DNBTScaleInfo const& param_0) {
- mbHasScale = param_0.mbHasScale;
- mScale = param_0.mScale;
+bool J3DNBTScaleInfo::operator==(const J3DNBTScaleInfo& other) const {
+ if (mbHasScale == other.mbHasScale &&
+ mScale.x == other.mScale.x &&
+ mScale.y == other.mScale.y &&
+ mScale.z == other.mScale.z
+ ) {
+ return true;
+ }
+ return false;
+}
+
+J3DNBTScaleInfo& J3DNBTScaleInfo::operator=(const J3DNBTScaleInfo& other) {
+ mbHasScale = other.mbHasScale;
+ mScale.x = other.mScale.x;
+ mScale.y = other.mScale.y;
+ mScale.z = other.mScale.z;
return *this;
}
diff --git a/src/JSystem/J3DGraphBase/J3DSys.cpp b/src/JSystem/J3DGraphBase/J3DSys.cpp
index fc59161b07..88324c30b5 100644
--- a/src/JSystem/J3DGraphBase/J3DSys.cpp
+++ b/src/JSystem/J3DGraphBase/J3DSys.cpp
@@ -69,7 +69,7 @@ J3DSys::J3DSys() {
}
void J3DSys::loadPosMtxIndx(int addr, u16 indx) const {
- // J3DFifoLoadPosMtxIndx(indx, addr * 3); // matches debug, not retail
+ //J3DFifoLoadPosMtxIndx(indx, addr * 3); // matches debug, not retail
J3DFifoLoadIndx(GX_LOAD_INDX_A, indx, 0xB000 | ((u16)(addr * 0x0C)));
}
diff --git a/src/JSystem/J3DGraphBase/J3DTevs.cpp b/src/JSystem/J3DGraphBase/J3DTevs.cpp
index c7cceac95c..d71aa20255 100644
--- a/src/JSystem/J3DGraphBase/J3DTevs.cpp
+++ b/src/JSystem/J3DGraphBase/J3DTevs.cpp
@@ -81,7 +81,7 @@ void J3DTexMtx::calcTexMtx(const Mtx param_0) {
};
u32 r28 = mTexMtxInfo.mInfo & 0x3f;
- u32 r30 = (mTexMtxInfo.mInfo >> 7) & 1;
+ u32 r30 = u32(mTexMtxInfo.mInfo & 0x80) >> 7;
switch (r28) {
case 8:
case 9:
@@ -176,7 +176,7 @@ void J3DTexMtx::calcPostTexMtx(const Mtx param_0) {
};
u32 r29 = mTexMtxInfo.mInfo & 0x3f;
- u32 r30 = (mTexMtxInfo.mInfo >> 7) & 1;
+ u32 r30 = u32(mTexMtxInfo.mInfo & 0x80) >> 7;
switch (r29) {
case 8:
case 11:
diff --git a/src/JSystem/J3DGraphBase/J3DTransform.cpp b/src/JSystem/J3DGraphBase/J3DTransform.cpp
index c1a246d104..9194e6e263 100644
--- a/src/JSystem/J3DGraphBase/J3DTransform.cpp
+++ b/src/JSystem/J3DGraphBase/J3DTransform.cpp
@@ -55,18 +55,22 @@ void J3DCalcBBoardMtx(__REGISTER Mtx mtx) {
__REGISTER f32 zero = 0.0f;
// zero out gaps of zeroes
-#ifdef __MWERKS__ // clang-format off
+#if DEBUG || !defined(__MWERKS__)
+ mtx[0][1] = 0.0f;
+ mtx[0][2] = 0.0f;
+ mtx[2][0] = 0.0f;
+ mtx[2][1] = 0.0f;
+#else // clang-format off
asm {
psq_st zero, 0x04(mtx), 0, 0
-
psq_st zero, 0x20(mtx), 0, 0
}
#endif // clang-format on
mtx[0][0] = x;
- mtx[1][0] = zero;
+ mtx[1][0] = 0.0f;
mtx[1][1] = y;
- mtx[1][2] = zero;
+ mtx[1][2] = 0.0f;
mtx[2][2] = z;
}
diff --git a/src/JSystem/J3DGraphBase/J3DVertex.cpp b/src/JSystem/J3DGraphBase/J3DVertex.cpp
index 3724aa6b94..d455f27c8c 100644
--- a/src/JSystem/J3DGraphBase/J3DVertex.cpp
+++ b/src/JSystem/J3DGraphBase/J3DVertex.cpp
@@ -210,6 +210,10 @@ s32 J3DVertexBuffer::allocTransformedVtxNrmArray() {
return kJ3DError_Success;
}
+static void dummy(J3DVertexData* vertexData) {
+ vertexData->getColNum();
+}
+
J3DDrawMtxData::J3DDrawMtxData() {
mEntryNum = 0;
mDrawMtxFlag = NULL;