summaryrefslogtreecommitdiff
path: root/libs/JSystem/src/J3DGraphAnimator/J3DModelData.cpp
diff options
context:
space:
mode:
authorLuke Street <luke@street.dev>2026-03-01 15:35:36 -0700
committerGitHub <noreply@github.com>2026-03-01 14:35:36 -0800
commit9649319ec4926457ef85e6094f8207474c977c2d (patch)
tree1c5cd4c7cc4c1aee03f28921213da47f2775444d /libs/JSystem/src/J3DGraphAnimator/J3DModelData.cpp
parent6e149819e13b1f70ecbf8a4c66b030c17ffed2bb (diff)
Reorganize library code into `libs/` (#3119)
* Reorganize files into libs/{dolphin,JSystem,PowerPC_EABI_Support,revolution,TRK_MINNOW_DOLPHIN} * Update configure.py and project.py for new libs structure * Refactor `#include <dolphin/x.h>` -> `<x.h>` * Remove `__REVOLUTION_SDK__` forwards from dolphin * Fix dolphin/ references in revolution * Wrap `#include <dolphin.h>` in `!__REVOLUTION_SDK__` * Always build TRK against dolphin headers * Resolve revolution SDK header resolution issues
Diffstat (limited to 'libs/JSystem/src/J3DGraphAnimator/J3DModelData.cpp')
-rw-r--r--libs/JSystem/src/J3DGraphAnimator/J3DModelData.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/libs/JSystem/src/J3DGraphAnimator/J3DModelData.cpp b/libs/JSystem/src/J3DGraphAnimator/J3DModelData.cpp
new file mode 100644
index 0000000000..606882eb0a
--- /dev/null
+++ b/libs/JSystem/src/J3DGraphAnimator/J3DModelData.cpp
@@ -0,0 +1,100 @@
+//
+// J3DModelData
+//
+
+#include "JSystem/JSystem.h" // IWYU pragma: keep
+
+#include "JSystem/J3DGraphAnimator/J3DModelData.h"
+#include "JSystem/J3DGraphAnimator/J3DJoint.h"
+#include "JSystem/J3DGraphAnimator/J3DMaterialAnm.h"
+#include "JSystem/J3DGraphAnimator/J3DModel.h"
+#include "JSystem/J3DGraphBase/J3DMaterial.h"
+
+void J3DModelData::clear() {
+ mpRawData = 0;
+ mFlags = 0;
+ mbHasBumpArray = 0;
+ mbHasBillboard = 0;
+}
+
+J3DModelData::J3DModelData() {
+ clear();
+}
+
+s32 J3DModelData::newSharedDisplayList(u32 mdlFlags) {
+ u16 matNum = getMaterialNum();
+
+ for (u16 i = 0; i < matNum; i++) {
+ s32 ret;
+ if (mdlFlags & J3DMdlFlag_UseSingleDL) {
+ ret = getMaterialNodePointer(i)->newSingleSharedDisplayList(getMaterialNodePointer(i)->countDLSize());
+ if (ret != kJ3DError_Success)
+ return ret;
+ } else {
+ ret = getMaterialNodePointer(i)->newSharedDisplayList(getMaterialNodePointer(i)->countDLSize());
+ if (ret != kJ3DError_Success)
+ return ret;
+ }
+ }
+
+ return kJ3DError_Success;
+}
+
+void J3DModelData::indexToPtr() {
+ j3dSys.setTexture(getTexture());
+
+ static BOOL sInterruptFlag = OSDisableInterrupts();
+ OSDisableScheduler();
+
+ GDLObj gdl_obj;
+ u16 matNum = getMaterialNum();
+ for (u16 i = 0; i < matNum; i++) {
+ J3DMaterial* matNode = getMaterialNodePointer(i);
+ J3DDisplayListObj* dl_obj = matNode->getSharedDisplayListObj();
+
+ GDInitGDLObj(&gdl_obj, dl_obj->getDisplayList(0), dl_obj->getDisplayListSize());
+ GDSetCurrent(&gdl_obj);
+ matNode->getTevBlock()->indexToPtr();
+ }
+
+ GDSetCurrent(NULL);
+ OSEnableScheduler();
+ OSRestoreInterrupts(sInterruptFlag);
+}
+
+void J3DModelData::makeSharedDL() {
+ j3dSys.setTexture(getTexture());
+
+ u16 matNum = getMaterialNum();
+ for (u16 i = 0; i < matNum; i++) {
+ getMaterialNodePointer(i)->makeSharedDisplayList();
+ }
+}
+
+void J3DModelData::simpleCalcMaterial(u16 idx, Mtx param_1) {
+ syncJ3DSysFlags();
+
+ J3DMaterial* mat;
+ J3DJoint* jointNode = getJointNodePointer(idx);
+ for (mat = jointNode->getMesh(); mat != NULL; mat = mat->getNext()) {
+ if (mat->getMaterialAnm() != NULL) {
+ mat->getMaterialAnm()->calc(mat);
+ }
+ mat->calc(param_1);
+ }
+}
+
+void J3DModelData::syncJ3DSysPointers() const {
+ j3dSys.setTexture(getTexture());
+ j3dSys.setVtxPos(getVtxPosArray());
+ j3dSys.setVtxNrm(getVtxNrmArray());
+ j3dSys.setVtxCol(getVtxColorArray(0));
+}
+
+void J3DModelData::syncJ3DSysFlags() const {
+ if (checkFlag(0x20)) {
+ j3dSys.onFlag(J3DSysFlag_PostTexMtx);
+ } else {
+ j3dSys.offFlag(J3DSysFlag_PostTexMtx);
+ }
+}