Files

246 lines
7.7 KiB
C++
Raw Permalink Normal View History

2021-04-01 02:07:58 +02:00
//
2021-03-28 22:49:05 +02:00
// Generated By: dol2asm
// Translation Unit: J3DVertex
2021-04-01 02:07:58 +02:00
//
2021-03-28 22:49:05 +02:00
2021-04-01 02:07:58 +02:00
#include "JSystem/J3DGraphBase/J3DVertex.h"
2021-10-11 09:38:53 -07:00
#include "JSystem/J3DGraphAnimator/J3DJointTree.h"
#include "JSystem/J3DGraphBase/J3DSys.h"
#include "JSystem/JKernel/JKRHeap.h"
#include "string.h"
2021-10-11 09:38:53 -07:00
#include "dolphin/os/OSCache.h"
#include "init.h"
2021-03-28 22:49:05 +02:00
2021-04-06 18:00:35 +02:00
/* 80310EF8-80310F78 30B838 0080+00 0/0 1/1 0/0 .text __ct__13J3DVertexDataFv */
2021-10-11 09:38:53 -07:00
J3DVertexData::J3DVertexData() {
mVtxNum = 0;
mNrmNum = 0;
mColNum = 0;
2022-04-24 01:41:27 -07:00
mTexCoordNum = 0;
mPacketNum = 0;
2021-10-11 09:38:53 -07:00
mVtxAttrFmtList = NULL;
mVtxPosArray = NULL;
mVtxNrmArray = NULL;
mVtxNBTArray = NULL;
2022-04-24 01:41:27 -07:00
for (int i = 0; i < ARRAY_SIZE(mVtxColorArray); i++)
2021-10-11 09:38:53 -07:00
mVtxColorArray[i] = NULL;
2022-04-24 01:41:27 -07:00
for (int i = 0; i < ARRAY_SIZE(mVtxTexCoordArray); i++)
2021-10-11 09:38:53 -07:00
mVtxTexCoordArray[i] = NULL;
mVtxPosFrac = 0;
mVtxPosType = GX_F32;
mVtxNrmFrac = 0;
mVtxNrmType = GX_F32;
2021-03-28 22:49:05 +02:00
}
2021-04-06 18:00:35 +02:00
/* 80310F78-80310FD8 30B8B8 0060+00 0/0 1/1 0/0 .text
2021-04-01 02:07:58 +02:00
* setVertexData__15J3DVertexBufferFP13J3DVertexData */
2021-10-11 09:38:53 -07:00
void J3DVertexBuffer::setVertexData(J3DVertexData* pVtxData) {
mVtxData = pVtxData;
mVtxPosArray[0] = pVtxData->getVtxPosArray();
mVtxNrmArray[0] = pVtxData->getVtxNrmArray();
mVtxColArray[0] = pVtxData->getVtxColorArray(0);
mVtxPosArray[1] = NULL;
mVtxNrmArray[1] = NULL;
mVtxColArray[1] = NULL;
mTransformedVtxPosArray[0] = pVtxData->getVtxPosArray();
mTransformedVtxNrmArray[0] = pVtxData->getVtxNrmArray();
mTransformedVtxPosArray[1] = NULL;
mTransformedVtxNrmArray[1] = NULL;
frameInit();
2021-03-28 22:49:05 +02:00
}
2021-04-06 18:00:35 +02:00
/* 80310FD8-80311030 30B918 0058+00 0/0 3/3 0/0 .text init__15J3DVertexBufferFv */
2021-10-11 09:38:53 -07:00
void J3DVertexBuffer::init() {
mVtxData = NULL;
mVtxPosArray[1] = NULL;
mVtxPosArray[0] = NULL;
mVtxNrmArray[1] = NULL;
mVtxNrmArray[0] = NULL;
mVtxColArray[1] = NULL;
mVtxColArray[0] = NULL;
mTransformedVtxPosArray[1] = NULL;
mTransformedVtxPosArray[0] = NULL;
mTransformedVtxNrmArray[1] = NULL;
mTransformedVtxNrmArray[0] = NULL;
mCurrentVtxPos = NULL;
mCurrentVtxNrm = NULL;
mCurrentVtxCol = NULL;
frameInit();
2021-03-28 22:49:05 +02:00
}
2021-04-06 18:00:35 +02:00
/* 80311030-8031106C 30B970 003C+00 0/0 1/1 0/0 .text __dt__15J3DVertexBufferFv */
2021-10-11 09:38:53 -07:00
J3DVertexBuffer::~J3DVertexBuffer() {}
2021-03-28 22:49:05 +02:00
2021-04-06 18:00:35 +02:00
/* 8031106C-80311090 30B9AC 0024+00 0/0 1/1 0/0 .text setArray__15J3DVertexBufferCFv */
2021-10-11 09:38:53 -07:00
void J3DVertexBuffer::setArray() const {
j3dSys.setVtxPos(mCurrentVtxPos);
j3dSys.setVtxNrm(mCurrentVtxNrm);
j3dSys.setVtxCol(mCurrentVtxCol);
2021-03-28 22:49:05 +02:00
}
2021-04-06 18:00:35 +02:00
/* 80311090-803111B0 30B9D0 0120+00 1/1 0/0 0/0 .text copyLocalVtxPosArray__15J3DVertexBufferFUl
2021-04-01 02:07:58 +02:00
*/
2022-04-24 01:34:15 -07:00
s32 J3DVertexBuffer::copyLocalVtxPosArray(u32 flag) {
if (flag & 1) {
2021-10-11 09:38:53 -07:00
for (int i = 0; i < 2; i++) {
mVtxPosArray[i] = new (0x20) Vec[mVtxData->getVtxNum()];
2021-10-11 09:38:53 -07:00
if (mVtxPosArray[i] == NULL) {
2022-04-24 01:34:15 -07:00
return kJ3DError_Alloc;
2021-10-11 09:38:53 -07:00
}
memcpy(mVtxPosArray[i], mVtxData->getVtxPosArray(), mVtxData->getVtxNum() * 12);
DCStoreRange(mVtxPosArray[i], mVtxData->getVtxNum() * 12);
}
} else {
mVtxPosArray[0] = mVtxData->getVtxPosArray();
if (mVtxPosArray[1] == NULL) {
mVtxPosArray[1] = new (0x20) Vec[mVtxData->getVtxNum()];
2021-10-11 09:38:53 -07:00
if (mVtxPosArray[1] == NULL) {
2022-04-24 01:34:15 -07:00
return kJ3DError_Alloc;
2021-10-11 09:38:53 -07:00
}
}
memcpy(mVtxPosArray[1], mVtxData->getVtxPosArray(), mVtxData->getVtxNum() * 12);
DCStoreRange(mVtxPosArray[1], mVtxData->getVtxNum() * 12);
}
2022-04-24 01:34:15 -07:00
return kJ3DError_Success;
2021-03-28 22:49:05 +02:00
}
2021-04-06 18:00:35 +02:00
/* 803111B0-803112D0 30BAF0 0120+00 1/1 0/0 0/0 .text copyLocalVtxNrmArray__15J3DVertexBufferFUl
2021-04-01 02:07:58 +02:00
*/
2022-04-24 01:34:15 -07:00
s32 J3DVertexBuffer::copyLocalVtxNrmArray(u32 flag) {
if (flag & 1) {
2021-10-11 09:38:53 -07:00
for (int i = 0; i < 2; i++) {
mVtxNrmArray[i] = new (0x20) VertexNormal[mVtxData->getNrmNum()];
if (mVtxNrmArray[i] == NULL) {
2022-04-24 01:34:15 -07:00
return kJ3DError_Alloc;
2021-10-11 09:38:53 -07:00
}
memcpy(mVtxNrmArray[i], mVtxData->getVtxNrmArray(), mVtxData->getNrmNum() * 12);
DCStoreRange(mVtxNrmArray[i], mVtxData->getNrmNum() * 12);
}
} else {
mVtxNrmArray[0] = mVtxData->getVtxNrmArray();
if (mVtxNrmArray[1] == NULL) {
mVtxNrmArray[1] = new (0x20) VertexNormal[mVtxData->getNrmNum()];
if (mVtxNrmArray[1] == NULL) {
2022-04-24 01:34:15 -07:00
return kJ3DError_Alloc;
2021-10-11 09:38:53 -07:00
}
}
memcpy(mVtxNrmArray[1], mVtxData->getVtxNrmArray(), mVtxData->getNrmNum() * 12);
DCStoreRange(mVtxNrmArray[1], mVtxData->getNrmNum() * 12);
}
2022-04-24 01:34:15 -07:00
return kJ3DError_Success;
2021-03-28 22:49:05 +02:00
}
2021-04-06 18:00:35 +02:00
/* 803112D0-80311478 30BC10 01A8+00 0/0 1/1 0/0 .text copyLocalVtxArray__15J3DVertexBufferFUl */
2022-04-24 01:34:15 -07:00
s32 J3DVertexBuffer::copyLocalVtxArray(u32 flag) {
void* oldPosArray[2];
void* oldNrmArray[2];
2021-10-11 09:38:53 -07:00
2022-04-24 01:34:15 -07:00
for (int i = 0; i < 2; i++)
oldPosArray[i] = mVtxPosArray[i];
2021-10-11 09:38:53 -07:00
2022-04-24 01:34:15 -07:00
if (~flag & 2) {
s32 ret = copyLocalVtxPosArray(flag);
if (ret != 0) {
2021-10-11 09:38:53 -07:00
for (int i = 0; i < 2; i++) {
2022-04-24 01:34:15 -07:00
if (oldPosArray[i] != mVtxPosArray[i]) {
if (mVtxPosArray[i] != mVtxData->getVtxPosArray())
2021-10-11 09:38:53 -07:00
delete mVtxPosArray[i];
2022-04-24 01:34:15 -07:00
mVtxPosArray[i] = oldPosArray[i];
2021-10-11 09:38:53 -07:00
}
}
2022-04-24 01:34:15 -07:00
return ret;
2021-10-11 09:38:53 -07:00
}
} else {
2022-04-24 01:34:15 -07:00
mVtxPosArray[0] = mVtxPosArray[1] = mVtxData->getVtxPosArray();
2021-10-11 09:38:53 -07:00
}
2022-04-24 01:34:15 -07:00
for (int i = 0; i < 2; i++)
oldNrmArray[i] = mVtxNrmArray[i];
2021-10-11 09:38:53 -07:00
2022-04-24 01:34:15 -07:00
if (~flag & 4) {
s32 ret = copyLocalVtxNrmArray(flag);
if (ret != 0) {
2021-10-11 09:38:53 -07:00
for (int i = 0; i < 2; i++) {
2022-04-24 01:34:15 -07:00
if (oldPosArray[i] != mVtxPosArray[i]) {
if (mVtxPosArray[i] != mVtxData->getVtxPosArray())
2021-10-11 09:38:53 -07:00
delete mVtxPosArray[i];
2022-04-24 01:34:15 -07:00
mVtxPosArray[i] = oldPosArray[i];
2021-10-11 09:38:53 -07:00
}
2022-04-24 01:34:15 -07:00
if (oldNrmArray[i] != mVtxNrmArray[i]) {
if (mVtxNrmArray[i] != mVtxData->getVtxNrmArray())
2021-10-11 09:38:53 -07:00
delete mVtxNrmArray[i];
2022-04-24 01:34:15 -07:00
mVtxNrmArray[i] = oldNrmArray[i];
2021-10-11 09:38:53 -07:00
}
}
2022-04-24 01:34:15 -07:00
return ret;
2021-10-11 09:38:53 -07:00
}
} else {
2022-04-24 01:34:15 -07:00
mVtxNrmArray[0] = mVtxNrmArray[1] = mVtxData->getVtxNrmArray();
2021-10-11 09:38:53 -07:00
}
2022-04-24 01:34:15 -07:00
return kJ3DError_Success;
2021-10-11 09:38:53 -07:00
}
2021-03-28 22:49:05 +02:00
2021-04-06 18:00:35 +02:00
/* 80311478-8031152C 30BDB8 00B4+00 0/0 1/1 0/0 .text
2021-04-01 02:07:58 +02:00
* allocTransformedVtxPosArray__15J3DVertexBufferFv */
2021-10-11 09:38:53 -07:00
s32 J3DVertexBuffer::allocTransformedVtxPosArray() {
2022-04-24 01:34:15 -07:00
if (mTransformedVtxPosArray[0] != NULL && mTransformedVtxPosArray[1] != NULL)
return kJ3DError_Success;
2021-10-11 09:38:53 -07:00
for (int i = 0; i < 2; i++) {
if (i == 0 || mTransformedVtxPosArray[i] == NULL) {
mTransformedVtxPosArray[i] = new (0x20) Vec[mVtxData->getVtxNum()];
2022-04-24 01:34:15 -07:00
if (mTransformedVtxPosArray[i] == NULL)
return kJ3DError_Alloc;
2021-10-11 09:38:53 -07:00
}
}
2022-04-24 01:34:15 -07:00
return kJ3DError_Success;
2021-03-28 22:49:05 +02:00
}
2021-04-06 18:00:35 +02:00
/* 8031152C-803115E0 30BE6C 00B4+00 0/0 1/1 0/0 .text
2021-04-01 02:07:58 +02:00
* allocTransformedVtxNrmArray__15J3DVertexBufferFv */
2021-10-11 09:38:53 -07:00
s32 J3DVertexBuffer::allocTransformedVtxNrmArray() {
2022-04-24 01:34:15 -07:00
if (mTransformedVtxNrmArray[0] != NULL && mTransformedVtxNrmArray[1] != NULL)
return kJ3DError_Success;
2021-10-11 09:38:53 -07:00
for (int i = 0; i < 2; i++) {
if (i == 0 || mTransformedVtxNrmArray[i] == NULL) {
mTransformedVtxNrmArray[i] = new (0x20) VertexNormal[mVtxData->getNrmNum()];
2022-04-24 01:34:15 -07:00
if (mTransformedVtxNrmArray[i] == NULL)
return kJ3DError_Alloc;
2021-10-11 09:38:53 -07:00
}
}
2022-04-24 01:34:15 -07:00
return kJ3DError_Success;
2021-03-28 22:49:05 +02:00
}
2021-04-06 18:00:35 +02:00
/* 803115E0-803115F4 30BF20 0014+00 0/0 1/1 0/0 .text __ct__14J3DDrawMtxDataFv */
2021-10-11 09:38:53 -07:00
J3DDrawMtxData::J3DDrawMtxData() {
mEntryNum = 0;
mDrawMtxFlag = NULL;
mDrawMtxIndex = NULL;
2021-03-28 22:49:05 +02:00
}
2021-04-06 18:00:35 +02:00
/* 803115F4-80311630 30BF34 003C+00 0/0 2/2 0/0 .text __dt__14J3DDrawMtxDataFv */
2021-10-11 09:38:53 -07:00
J3DDrawMtxData::~J3DDrawMtxData() {}