Misc Collision (#51)

* Initial Commit - Starting to translate from TP

* Collision Updates

* Actor Collision -> dBgW (DZB Collision)

* bg .text splits complete

* fix errors

* file organization

* missed files

* progress

* weee

* most of cM3dG

* Revert mAng change

* Progress

* Progress -> Need to update from main

* Fixup Merge

* d_bg_s symbols....

* TList Changes

* oops

* d_bg_s large progress

* d_bg_s_acch majority done

* d_bg_s_chk OK

* d_bg_s_gnd_chk OK

* d_bg_s_grp_pass_chk OK

* d_bg_lin_chk OK

* d_bg_s_poly_pass_chk OK

* d_bg_s_roof_chk and d_bg_s_sph_chk OK

* d_bg_s_spl_grp_chk OK

* d_bg_s_wtr_chk OK

* d_bg_w started

* d_bg_w_base OK

* name d_bg_w_kcol symbols

* d_bg_w_sv split/started

* most of d_bg_w_time

* stopping d_bg_w_kcol for now

* d_bg_w_sv OK

* work on d_bg_w_time

* revert TList to take offset arg

* fixup some compiler warnings

* set c_bg_w OK

* Update rel_sieve.py

* Remove TList Macros

* Bomb Header started
This commit is contained in:
Elijah Thomas
2024-10-16 09:00:47 -04:00
committed by GitHub
parent ec4d28cd25
commit b5aa43ff37
145 changed files with 10710 additions and 1571 deletions
+4 -7
View File
@@ -1,5 +1,6 @@
#include <d/a/d_a_t_wood_area.h>
#include <d/a/d_a_player.h>
#include <d/a/d_a_t_wood_area.h>
const f32 dAcTWoodArea_c::scaleX = 100.0f;
const f32 dAcTWoodArea_c::scaleY = 100.0f;
@@ -11,18 +12,14 @@ STATE_DEFINE(dAcTWoodArea_c, Wait);
int dAcTWoodArea_c::actorCreate() {
mStateMgr.changeState(StateID_Init);
PSMTXTrans(worldMatrix.m, position.x, position.y, position.z);
PSMTXTrans(mWorldMtx.m, position.x, position.y, position.z);
boundingBox.min = mVec3_c(-0.0f, -0.0f, -0.0f);
boundingBox.max = mVec3_c(0.0f, 0.0f, 0.0f);
return SUCCEEDED;
}
static const ProfileName FILTER_PROFILE[] = {
fProfile::OBJ_FRUIT,
fProfile::ITEM,
fProfile::NPC_KYUI_THIRD,
fProfile::OBJ_IVY_ROPE,
fProfile::NPC_SORAJIMA_BOY,
fProfile::OBJ_FRUIT, fProfile::ITEM, fProfile::NPC_KYUI_THIRD, fProfile::OBJ_IVY_ROPE, fProfile::NPC_SORAJIMA_BOY,
};
int dAcTWoodArea_c::actorPostCreate() {
+10 -19
View File
@@ -27,23 +27,14 @@ int dAcEhb_leaf_c::create() {
someRot = rotation.y.mVal;
switch (getParam1()) {
case 0:
case 7:
mType = 0;
break;
case 1:
mType = 1;
break;
case 2:
mType = 2;
break;
case 3:
case 4:
case 5:
rotation.z = -0x8000;
break;
default:
break;
case 0:
case 7: mType = 0; break;
case 1: mType = 1; break;
case 2: mType = 2; break;
case 3:
case 4:
case 5: rotation.z = -0x8000; break;
default: break;
}
if (mType == 0) {
@@ -85,9 +76,9 @@ int dAcEhb_leaf_c::actorExecute() {
if (mType != 0) {
Mtx m;
PSMTXScale(m, mTimeAreaStruct.field_0x00, mTimeAreaStruct.field_0x00, mTimeAreaStruct.field_0x00);
PSMTXConcat(worldMatrix.m, m, worldMatrix.m);
PSMTXConcat(mWorldMtx.m, m, mWorldMtx.m);
}
mModel.getModel().setLocalMtx(worldMatrix);
mModel.getModel().setLocalMtx(mWorldMtx);
mModel.getModel().calc(false);
someRot++;
+9 -8
View File
@@ -1,5 +1,6 @@
#include <d/a/d_a_player.h>
#include <d/a/obj/d_a_obj_appear_bridge.h>
#include <d/col/bg/d_bg_s.h>
#include <toBeSorted/area_utils.h>
SPECIAL_ACTOR_PROFILE(OBJ_APPEAR_BRIDGE, dAcOappearBridge_c, fProfile::OBJ_APPEAR_BRIDGE, 0x01FC, 0, 6);
@@ -21,18 +22,18 @@ bool dAcOappearBridge_c::createHeap() {
TRY_CREATE(mSrtAnm.create(mdl, srt, &heap_allocator, nullptr, 1));
nw4r::g3d::ResAnmClr clr = mResFile.GetResAnmClr("TongueStage");
TRY_CREATE(mClrAnm.create(mdl, clr, &heap_allocator, nullptr, 1));
void *dzb = getOarcFile("TongueStage", "dzb/TongueStage.dzb");
void *plc = getOarcFile("TongueStage", "dat/TongueStage.plc");
cBgD_t *dzb = (cBgD_t *)getOarcFile("TongueStage", "dzb/TongueStage.dzb");
PLC *plc = (PLC *)getOarcFile("TongueStage", "dat/TongueStage.plc");
updateMatrix();
mModel.setLocalMtx(worldMatrix);
TRY_CREATE(mCollision.create(dzb, plc, true, worldMatrix, scale) == nullptr);
mCollision.init();
mModel.setLocalMtx(mWorldMtx);
TRY_CREATE(!mCollision.Set(dzb, plc, 1, &mWorldMtx, &mScale));
mCollision.Lock();
return true;
}
int dAcOappearBridge_c::create() {
CREATE_ALLOCATOR(dAcOappearBridge_c);
CollisionCheckContext::get()->registerActorBgCollision(mCollision, this);
dBgS::GetInstance()->Regist(&mCollision, this);
mAreaIdx = params & 0xFF;
mEventId = (params >> 8) & 0xFF;
mSoundPosition = position + positionOffset;
@@ -65,7 +66,7 @@ int dAcOappearBridge_c::draw() {
}
void dAcOappearBridge_c::initializeState_Wait() {
CollisionCheckContext::get()->destroyActorBgCollision(mCollision);
dBgS::GetInstance()->Release(&mCollision);
}
void dAcOappearBridge_c::executeState_Wait() {
if (checkPosInArea(mAreaIdx, roomid, dAcPy_c::LINK->position, nullptr)) {
@@ -89,7 +90,7 @@ void dAcOappearBridge_c::finalizeState_Wait() {
void dAcOappearBridge_c::initializeState_Appear() {
mSrtAnm.setRate(sMovementRate, 0);
mClrAnm.setRate(sMovementRate, 0);
CollisionCheckContext::get()->registerActorBgCollision(mCollision, this);
dBgS::GetInstance()->Regist(&mCollision, this);
playSound(0xAA4);
}
void dAcOappearBridge_c::executeState_Appear() {
+11 -10
View File
@@ -1,17 +1,18 @@
#include <d/a/obj/d_a_obj_bamboo_island.h>
#include <d/col/bg/d_bg_s.h>
#include <toBeSorted/item_story_flag_manager.h>
const f32 dAcObambooIsland_c::unusedFloat1 = 100000.0f;
const f32 dAcObambooIsland_c::unusedFloat2 = 0.0f;
static const char *const sBambooIslandNames[] = {
"IslBamb",
"IslBamb_s",
"IslBamb",
"IslBamb_s",
};
SPECIAL_ACTOR_PROFILE(OBJ_BAMBOO_ISLAND, dAcObambooIsland_c, fProfile::OBJ_BAMBOO_ISLAND, 0x01F9, 0, 3);
void dAcObambooIsland_c::interactCallback(void *unknown, dAcBase_c *actor, dAcObjBase_c *interactor) {
void dAcObambooIsland_c::rideCallback(dBgW *unknown, dAcObjBase_c *actor, dAcObjBase_c *interactor) {
if (interactor->isActorPlayer() && actor != nullptr && StoryFlagManager::sInstance->getCounterOrFlag(284) == 0) {
StoryFlagManager::sInstance->setFlag(284);
}
@@ -25,26 +26,26 @@ bool dAcObambooIsland_c::createHeap() {
nw4r::g3d::ResMdl mdl = mBrres.GetResMdl(sBambooIslandNames[i]);
TRY_CREATE(mModels[i].create(mdl, &heap_allocator, 0x120));
}
void *dzb = getOarcFile("IslBamb", "dzb/IslBamb.dzb");
void *plc = getOarcFile("IslBamb", "dat/IslBamb.plc");
cBgD_t *dzb = (cBgD_t *)getOarcFile("IslBamb", "dzb/IslBamb.dzb");
PLC *plc = (PLC *)getOarcFile("IslBamb", "dat/IslBamb.plc");
updateMatrix();
for (int i = 0; i < 2; i++) {
mModels[i].setLocalMtx(worldMatrix);
mModels[i].setLocalMtx(mWorldMtx);
}
TRY_CREATE(mCollision.create(dzb, plc, true, worldMatrix, scale) == nullptr);
mCollision.init();
TRY_CREATE(!mCollision.Set(dzb, plc, 1, &mWorldMtx, &mScale));
mCollision.Lock();
return true;
}
int dAcObambooIsland_c::create() {
CREATE_ALLOCATOR(dAcObambooIsland_c);
CollisionCheckContext::get()->registerActorBgCollision(mCollision, this);
dBgS::GetInstance()->Regist(&mCollision, this);
mModels[0].setPriorityDraw(0x1C, 9);
mModels[1].setPriorityDraw(0x22, 9);
setBoundingBox(mVec3_c(-2400.0f, -1600.0f, -2300.0f), mVec3_c(2400.0f, 3900.0f, 2400.0f));
mCullingDistance = 500000.0f;
mCollision.interactFunc = interactCallback;
mCollision.SetRideCallback(rideCallback);
return SUCCEEDED;
}
+2 -5
View File
@@ -37,10 +37,7 @@ int dAcOJunkRep_c::create() {
mStateMgr.changeState(StateID_Wait);
setBoundingBox(
mVec3_c(-30.0f, -0.0f, -20.0f),
mVec3_c(30.0f, 120.0f, 20.0f)
);
setBoundingBox(mVec3_c(-30.0f, -0.0f, -20.0f), mVec3_c(30.0f, 120.0f, 20.0f));
return SUCCEEDED;
}
@@ -52,7 +49,7 @@ int dAcOJunkRep_c::doDelete() {
int dAcOJunkRep_c::actorExecute() {
mStateMgr.executeState();
updateMatrix();
mpModelToUse->setLocalMtx(worldMatrix);
mpModelToUse->setLocalMtx(mWorldMtx);
return SUCCEEDED;
}
+1 -1
View File
@@ -34,7 +34,7 @@ int dAcOlavaF200_c::create() {
updateMatrix();
for (int i = 0; i < 2; i++) {
mModels[i].setLocalMtx(worldMatrix);
mModels[i].setLocalMtx(mWorldMtx);
}
mModels[0].setPriorityDraw(0x1C, 9);
+17 -17
View File
@@ -30,7 +30,7 @@ int dAcOmoleSoil_c::create() {
CREATE_ALLOCATOR(dAcOmoleSoil_c);
mScale = sHalfScale;
scale.set(sHalfScale, sHalfScale, sHalfScale);
dAcBase_c::mScale.set(sHalfScale, sHalfScale, sHalfScale);
mStateMgr.changeState(StateID_Wait);
setBoundingBox(mVec3_c(-100.0f, -0.0f, -100.0f), mVec3_c(100.0f, 100.0f, 100.0f));
@@ -43,25 +43,25 @@ int dAcOmoleSoil_c::doDelete() {
int dAcOmoleSoil_c::actorExecute() {
switch (getNextState()) {
case 1:
if (!mStateMgr.isState(StateID_Appear)) {
mStateMgr.changeState(StateID_Appear);
}
break;
case 2:
if (!mStateMgr.isState(StateID_DisAppear)) {
mStateMgr.changeState(StateID_DisAppear);
}
break;
case 3:
if (!mStateMgr.isState(StateID_Appear)) {
mStateMgr.changeState(StateID_Appear);
}
break;
case 1:
if (!mStateMgr.isState(StateID_Appear)) {
mStateMgr.changeState(StateID_Appear);
}
break;
case 2:
if (!mStateMgr.isState(StateID_DisAppear)) {
mStateMgr.changeState(StateID_DisAppear);
}
break;
case 3:
if (!mStateMgr.isState(StateID_Appear)) {
mStateMgr.changeState(StateID_Appear);
}
break;
}
mStateMgr.executeState();
updateMatrix();
mModel.setLocalMtx(worldMatrix);
mModel.setLocalMtx(mWorldMtx);
return SUCCEEDED;
}
+2 -2
View File
@@ -52,8 +52,8 @@ int dAcOPoolCock_c::actorExecute() {
updateMatrix();
mMtx_c mdl1Transform;
mMtx_c mdl2Transform;
mdl1Transform = worldMatrix;
mdl2Transform = worldMatrix;
mdl1Transform = mWorldMtx;
mdl2Transform = mWorldMtx;
mMtx_c tmp1;
mMtx_c tmp2;
+2 -2
View File
@@ -23,7 +23,7 @@ int dAcOPumpkinLeaf_c::create() {
mStateMgr.changeState(StateID_Wait);
setBoundingBox(mVec3_c(-50.0f, -10.0f, -50.0f), mVec3_c(50.0f, 50.0f, 50.0f));
dAcObjBase_c::create(
"PmpknBd", getRoomId(), 0, &position, &rotation, &scale, getParams2_ignoreLower(), -1, viewclip_index
"PmpknBd", getRoomId(), 0, &position, &rotation, &mScale, getParams2_ignoreLower(), -1, viewclip_index
);
return SUCCEEDED;
}
@@ -33,7 +33,7 @@ int dAcOPumpkinLeaf_c::doDelete() {
}
int dAcOPumpkinLeaf_c::actorExecute() {
mModel.setLocalMtx(worldMatrix);
mModel.setLocalMtx(mWorldMtx);
return SUCCEEDED;
}
+4 -4
View File
@@ -1,5 +1,5 @@
#include <d/a/obj/d_a_obj_ring.h>
#include <d/a/d_a_player.h>
#include <d/a/obj/d_a_obj_ring.h>
SPECIAL_ACTOR_PROFILE(OBJ_RING, dAcOring_c, fProfile::OBJ_RING, 0x00f2, 0, 0x103);
@@ -20,8 +20,8 @@ int dAcOring_c::create() {
setBoundingBox(mVec3_c(-100.0f, -100.0f, -100.0f), mVec3_c(100.0f, 100.0f, 100.0f));
updateMatrix();
mModel.setScale(scale);
mModel.setLocalMtx(worldMatrix);
mModel.setScale(mScale);
mModel.setLocalMtx(mWorldMtx);
forwardAccel = -5.0f;
forwardMaxSpeed = -40.0f;
field_0x38C = dAcPy_c::LINK->position.y;
@@ -39,7 +39,7 @@ int dAcOring_c::actorExecute() {
position += velocity;
position += mCCdStruct.posIncrements;
updateMatrix();
mModel.setLocalMtx(worldMatrix);
mModel.setLocalMtx(mWorldMtx);
return SUCCEEDED;
}
+5 -5
View File
@@ -1,13 +1,13 @@
#include <d/a/obj/d_a_obj_smoke.h>
static const char *const sSmokeNames1[] = {
"SmokeF200",
"SmokeF202",
"SmokeF200",
"SmokeF202",
};
static const char *const sSmokeNames2[] = {
"SmokeF200",
"SmokeF202",
"SmokeF200",
"SmokeF202",
};
SPECIAL_ACTOR_PROFILE(OBJ_SMOKE, dAcOsmoke_c, fProfile::OBJ_SMOKE, 0x01DB, 0, 4);
@@ -29,7 +29,7 @@ int dAcOsmoke_c::create() {
mModel.setAnm(mTexAnm);
updateMatrix();
mModel.setLocalMtx(worldMatrix);
mModel.setLocalMtx(mWorldMtx);
mStateMgr.changeState(StateID_Wait);
mModel.setPriorityDraw(0x1C, 9);
setBoundingBox(mVec3_c(-0.0f, -0.0f, -0.0f), mVec3_c(0.0f, 0.0f, 0.0f));
+5 -5
View File
@@ -1,5 +1,5 @@
#include <d/a/obj/d_a_obj_spike.h>
#include <toBeSorted/cc/d_cc_mgr.h>
#include <d/col/cc/d_cc_mgr.h>
SPECIAL_ACTOR_PROFILE(OBJ_SPIKE, dAcOspike_c, fProfile::OBJ_SPIKE, 0x1D9, 0, 2);
@@ -33,9 +33,9 @@ int dAcOspike_c::create() {
mCollision.initUnk(mCCdStruct);
updateMatrix();
mMdl.setLocalMtx(worldMatrix);
mMdl.setLocalMtx(mWorldMtx);
mVec3_c tmp;
PSMTXMultVecSR(worldMatrix.m, mVec3_c::Ex, tmp);
PSMTXMultVecSR(mWorldMtx.m, mVec3_c::Ex, tmp);
mCollision.setAtVec(tmp);
mMtx_c mtx;
@@ -61,7 +61,7 @@ int dAcOspike_c::create() {
tmp3.z = copy;
}
mCollision.setMinMax(tmp2, tmp3);
mCollision.Set(tmp2, tmp3);
mStateMgr.changeState(StateID_Wait);
setBoundingBox(mVec3_c(-10.0f, -250.0f, -480.0f), mVec3_c(80.0f, 260.0f, 490.0f));
return SUCCEEDED;
@@ -73,7 +73,7 @@ int dAcOspike_c::doDelete() {
int dAcOspike_c::actorExecute() {
mStateMgr.executeState();
mCollision.setWithYRot(position, rotation.y);
mCollision.Set(position, rotation.y);
ColliderManager::getColliderManager()->addCollider(&mCollision);
return 1;
}
+1 -1
View File
@@ -28,7 +28,7 @@ int dAcOstageCover_c::doDelete() {
int dAcOstageCover_c::actorExecute() {
mStateMgr.executeState();
updateMatrix();
mModel.setLocalMtx(worldMatrix);
mModel.setLocalMtx(mWorldMtx);
return SUCCEEDED;
}
+1 -1
View File
@@ -38,7 +38,7 @@ int dAcOsunLight_c::actorExecute() {
mTexAnm.play();
}
updateMatrix();
mModel.setLocalMtx(worldMatrix);
mModel.setLocalMtx(mWorldMtx);
return SUCCEEDED;
}
@@ -1,6 +1,6 @@
#include <d/a/obj/d_a_obj_toD3_stone_figure.h>
#include <d/col/cc/d_cc_mgr.h>
#include <toBeSorted/attention.h>
#include <toBeSorted/cc/d_cc_mgr.h>
#include <toBeSorted/event.h>
#include <toBeSorted/event_manager.h>
#include <toBeSorted/item_story_flag_manager.h>
@@ -39,14 +39,14 @@ int dAcOtoD3StoneFigure_c::create() {
return FAILED;
}
mMdl.setLocalMtx(worldMatrix);
mMdl.setLocalMtx(mWorldMtx);
mCCdStruct.setField0x38ToMagicValue();
mCollision.init(sCcSrc);
mCollision.initUnk(mCCdStruct);
int zero = 0;
mCollision.setC(position);
mCollision.setR(dAcOtoD3StoneFigure_c::sRadius + zero);
mCollision.setH(dAcOtoD3StoneFigure_c::sHeight + zero);
mCollision.SetC(position);
mCollision.SetR(dAcOtoD3StoneFigure_c::sRadius + zero);
mCollision.SetH(dAcOtoD3StoneFigure_c::sHeight + zero);
ColliderManager::getColliderManager()->addCollider(&mCollision);
// mCollision.clearCoFlag();
mCollision.setTgCoFlag(1);
@@ -96,7 +96,7 @@ void dAcOtoD3StoneFigure_c::initializeState_OneEye() {
if (ScGame::currentSpawnInfo.night == 1) {
rotation.y.mVal += -0x8000;
updateMatrix();
mMdl.setLocalMtx(worldMatrix);
mMdl.setLocalMtx(mWorldMtx);
}
}
+10 -10
View File
@@ -1,7 +1,7 @@
#include <c/c_math.h>
#include <d/a/obj/d_a_obj_triforce.h>
#include <d/col/cc/d_cc_mgr.h>
#include <m/m_vec.h>
#include <toBeSorted/cc/d_cc_mgr.h>
SPECIAL_ACTOR_PROFILE(OBJ_TRIFORCE, dAcOtriforce_c, fProfile::OBJ_TRIFORCE, 0x15D, 0, 4);
@@ -42,10 +42,10 @@ int dAcOtriforce_c::create() {
mEffects.init(this);
mCollision.setSomeDefendValue(0x2000);
updateMatrix();
scale.x = sScale;
scale.y = sScale;
scale.z = sScale;
mMdl.setLocalMtx(worldMatrix);
mScale.x = sScale;
mScale.y = sScale;
mScale.z = sScale;
mMdl.setLocalMtx(mWorldMtx);
return SUCCEEDED;
}
@@ -62,16 +62,16 @@ int dAcOtriforce_c::actorExecute() {
position = mStartingPos + offset;
mStartingOffset.mVal += 0x16C;
mCollision.setC(position.x, position.y + 90.0f + zero, position.z);
mCollision.SetC(position.x, position.y + 90.0f + zero, position.z);
ColliderManager::getColliderManager()->addCollider(&mCollision);
updateMatrix();
Mtx m;
PSMTXScale(m, scale.x, scale.y, scale.z);
PSMTXConcat(worldMatrix.m, m, worldMatrix.m);
mMdl.setLocalMtx(worldMatrix);
PSMTXScale(m, mScale.x, mScale.y, mScale.z);
PSMTXConcat(mWorldMtx.m, m, mWorldMtx.m);
mMdl.setLocalMtx(mWorldMtx);
mAnm.play();
fn_80029AE0(&mEffects, PARTICLE_RESOURCE_ID_MAPPING_967_, &worldMatrix, nullptr, nullptr);
fn_80029AE0(&mEffects, PARTICLE_RESOURCE_ID_MAPPING_967_, &mWorldMtx, nullptr, nullptr);
return 1;
}
+5 -4
View File
@@ -52,7 +52,8 @@ void dTgFairy_c::createFairies() {
mVec3_c v = calcLocation(f);
v2 = v;
dAcObjFairy_c *ac = static_cast<dAcObjFairy_c *>(
dAcObjBase_c::create("Fairy", roomid, fairyParams1, &v2, nullptr, nullptr, -1, -1, viewclip_index));
dAcObjBase_c::create("Fairy", roomid, fairyParams1, &v2, nullptr, nullptr, -1, -1, viewclip_index)
);
if (ac != nullptr) {
mpFairyRefs[i].link(ac);
}
@@ -62,9 +63,9 @@ void dTgFairy_c::createFairies() {
mVec3_c dTgFairy_c::calcLocation(const f32 &offset) {
mVec3_c v;
v.y = scale.y * 0.5f;
v.x = scale.x * calcRnd(0.5f, offset);
v.z = scale.z * calcRnd(0.5f, offset);
v.y = mScale.y * 0.5f;
v.x = mScale.x * calcRnd(0.5f, offset);
v.z = mScale.z * calcRnd(0.5f, offset);
v.rotY(rotation.y);
return position + v;
}
+4 -5
View File
@@ -1,7 +1,7 @@
#include <d/t/d_t_genki_dws_tgt.h>
#include <toBeSorted/item_story_flag_manager.h>
#include <toBeSorted/room_manager.h>
#include <toBeSorted/sceneflag_manager.h>
#include <toBeSorted/item_story_flag_manager.h>
#include <toBeSorted/scgame.h>
SPECIAL_ACTOR_PROFILE(TAG_GENKI_DOWSING_TARGET, dTgGenkiDwsTgt_c, fProfile::TAG_GENKI_DOWSING_TARGET, 0x02A5, 0, 0);
@@ -22,7 +22,6 @@ int dTgGenkiDwsTgt_c::create() {
return FAILED;
}
int roomId_tmp = roomid;
if (addActorToRoom(-1)) {
roomid = roomId_tmp;
@@ -30,9 +29,9 @@ int dTgGenkiDwsTgt_c::create() {
} else {
return FAILED;
}
scale.x = 1.0f;
scale.y = 1.0f;
scale.z = 1.0f;
mScale.x = 1.0f;
mScale.y = 1.0f;
mScale.z = 1.0f;
static mVec3_c offset(0.0f, 25.0f, 0.0f);
mDowsingTarget.initialize(DowsingTarget::SLOT_CRYSTAL, 0, &offset, 1.0f);
+4 -4
View File
@@ -29,10 +29,10 @@ int dTgHolyWater_c::draw() {
}
bool dTgHolyWater_c::isLinkNearby() {
mVec3_c diff = dAcPy_c::LINK->position - (position + mVec3_c::Ey * scale.y * 0.5f);
diff.x /= scale.x;
diff.y /= scale.y;
diff.z /= scale.z;
mVec3_c diff = dAcPy_c::LINK->position - (position + mVec3_c::Ey * mScale.y * 0.5f);
diff.x /= mScale.x;
diff.y /= mScale.y;
diff.z /= mScale.z;
return diff.x <= 0.5f && diff.x >= -0.5f && diff.y <= 0.5f && diff.y >= -0.5f && diff.z <= 0.5f && diff.z >= -0.5f;
}
+1 -1
View File
@@ -8,7 +8,7 @@ const f32 dTgNoEffectArea_c::sFloat1 = 100.0f;
const f32 dTgNoEffectArea_c::sFloat2 = 100.0f;
int dTgNoEffectArea_c::create() {
scale *= 0.01f;
mScale *= 0.01f;
PSMTXTrans(mMtx, position.x, position.y, position.z);
mMtx.YrotM(rotation.y);
PSMTXInverse(mMtx, mMtx);
+30 -41
View File
@@ -1,5 +1,6 @@
#include <d/a/obj/d_a_obj_base.h>
#include <d/a/d_a_player.h>
#include <d/a/obj/d_a_obj_base.h>
#include <d/col/c/c_m3d_g_cps.h>
#include <d/t/d_t_sound_area.h>
#include <d/t/d_t_sound_area_mgr.h>
#include <rvl/MTX.h>
@@ -12,20 +13,18 @@ void float_ordering() {
}
int dTgSndAr_c::create() {
scale *= 0.01f;
mScale *= 0.01f;
if (dTgSndMg_c::sInstance == nullptr) {
dAcObjBase_c::createActorUnkGroup3(fProfile::SOUND_AREA_MGR, roomid, 0, nullptr, nullptr, nullptr, -1);
}
switch (getTypeFromParams()) {
case 0:
PSMTXTrans(mtx.m, position.x, position.y, position.z);
mtx.YrotM(rotation.y);
PSMTXInverse(mtx.m, mtx.m);
break;
case 3:
mRail.init(params >> 8 & 0xFF, roomid, 0);
break;
case 0:
PSMTXTrans(mtx.m, position.x, position.y, position.z);
mtx.YrotM(rotation.y);
PSMTXInverse(mtx.m, mtx.m);
break;
case 3: mRail.init(params >> 8 & 0xFF, roomid, 0); break;
}
fBase_c *base = nullptr;
@@ -72,14 +71,10 @@ int dTgSndAr_c::draw() {
bool dTgSndAr_c::checkPosInArea(mVec3_c &pos) {
switch (getTypeFromParams()) {
case 0:
return checkAlg0(pos);
case 1:
return checkAlg1(pos);
case 2:
return checkAlg2(pos);
case 3:
return checkAlg3(pos);
case 0: return checkAlg0(pos);
case 1: return checkAlg1(pos);
case 2: return checkAlg2(pos);
case 3: return checkAlg3(pos);
}
return false;
@@ -93,15 +88,15 @@ inline bool inRange(f32 val, f32 tolerance) {
bool dTgSndAr_c::checkAlg0(const mVec3_c &pos) {
mVec3_c c2 = pos;
PSMTXMultVec(mtx.m, c2, c2);
f32 sxLower = -50.0f * scale.x;
f32 sxUpper = 50.0f * scale.x;
f32 sxLower = -50.0f * mScale.x;
f32 sxUpper = 50.0f * mScale.x;
f32 syLower = 0.0f;
f32 syUpper = 100.0f * scale.y;
f32 szLower = -50.0f * scale.z;
f32 szUpper = 50.0f * scale.z;
f32 syUpper = 100.0f * mScale.y;
f32 szLower = -50.0f * mScale.z;
f32 szUpper = 50.0f * mScale.z;
if (sxLower <= c2.x && c2.x <= sxUpper && syLower <= c2.y && c2.y <= syUpper && szLower <= c2.z &&
c2.z <= szUpper) {
c2.z <= szUpper) {
return true;
}
return false;
@@ -109,18 +104,18 @@ bool dTgSndAr_c::checkAlg0(const mVec3_c &pos) {
// Sphere
bool dTgSndAr_c::checkAlg1(const mVec3_c &pos) {
f32 tgtDist = scale.x * 100.0f;
f32 tgtDist = mScale.x * 100.0f;
f32 tgtDist2 = tgtDist * tgtDist;
return PSVECSquareDistance(position, pos) < tgtDist2;
}
// Cylinder
bool dTgSndAr_c::checkAlg2(const mVec3_c &pos) {
if (pos.y < position.y || pos.y > (position.y + 100.0f * scale.y)) {
if (pos.y < position.y || pos.y > (position.y + 100.0f * mScale.y)) {
return false;
}
f32 radius = scale.x * 100.0f;
f32 radius = mScale.x * 100.0f;
mVec3_c diff = pos - position;
f32 dist = diff.x * diff.x + diff.z * diff.z;
@@ -138,38 +133,32 @@ struct UnkStruct {
/* 0x24 */ u32 field_0x24;
};
extern "C" void fn_80337EA0(UnkStruct *);
extern "C" void fn_80337EF0(UnkStruct *, mVec3_c &, mVec3_c &, f32);
extern "C" int cM3d_Len3dSqPntAndSegLine(UnkStruct *, Vec &, Vec *, f32 *, f32 *);
// Capsule
bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) {
Vec q;
mVec3_c q;
f32 radius = scale.x * 100.0f;
f32 radius = mScale.x * 100.0f;
radius = radius * radius;
Vec a = pos;
UnkStruct unk;
fn_80337EA0(&unk);
nw4r::math::VEC3 a = pos;
cM3dGCps unk;
// Line between b and c
mVec3_c b = *mRail.getPntPosForIndex(0);
mVec3_c c = *mRail.getPntPosForIndex(1);
fn_80337EF0(&unk, b, c, scale.x * 100.0f);
unk.Set(b, c, mScale.x * 100.0f);
f32 d;
if (cM3d_Len3dSqPntAndSegLine(&unk, a, &q, &d, nullptr)) {
if (cM3d_Len3dSqPntAndSegLine(&unk, &a, &q, &d, nullptr)) {
// At the cylindrical part of the capsule, just check the distance to
// the line
return d < radius;
} else {
// Otherwise check if we are within the spheres around the endpoints
f32 distSq = PSVECSquareDistance(unk.vec, pos);
f32 distSq = PSVECSquareDistance(unk.GetStart(), pos);
if (distSq < radius) {
return true;
} else {
distSq = PSVECSquareDistance(unk.vec2, pos);
distSq = PSVECSquareDistance(unk.GetEnd(), pos);
return distSq < radius;
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ int dTgTouchTag::create() {
mActivatorIndex = !(getActivatorIndex() == 0xF) ? getActivatorIndex() : 0;
mZoneFlag = getZoneFlag();
mChkFlag = getChkFlag();
matrixCreateFromPosRotYScale(mAreaOfEffect, position, rotation.y, scale, nullptr, 0.0f);
matrixCreateFromPosRotYScale(mAreaOfEffect, position, rotation.y, mScale, nullptr, 0.0f);
mStateMgr.changeState(StateID_Wait);
return SUCCEEDED;
}
+3 -3
View File
@@ -47,7 +47,7 @@ void dTgTumbleWeed_c::executeState_AreaOut() {
return;
}
}
if (isWithinPlayerRadius(scale.x)) {
if (isWithinPlayerRadius(mScale.x)) {
mStateMgr.changeState(StateID_AreaIn);
}
}
@@ -68,7 +68,7 @@ void dTgTumbleWeed_c::executeState_AreaIn() {
return;
}
}
if (!isWithinPlayerRadius(scale.x)) {
if (!isWithinPlayerRadius(mScale.x)) {
mStateMgr.changeState(StateID_AreaOut);
}
}
@@ -84,7 +84,7 @@ void dTgTumbleWeed_c::initializeState_Wind() {
}
void dTgTumbleWeed_c::executeState_Wind() {
if (isWithinPlayerRadius(scale.x)) {
if (isWithinPlayerRadius(mScale.x)) {
mStateMgr.changeState(StateID_AreaIn);
} else {
mStateMgr.changeState(StateID_AreaOut);
+33 -21
View File
@@ -1,6 +1,7 @@
#include "d/a/d_a_base.h"
#include "d/a/obj/d_a_obj_base.h"
#include "d/a/d_a_player.h"
#include "d/a/obj/d_a_obj_base.h"
#include "f/f_list_nd.h"
#include "m/m_vec.h"
#include "toBeSorted/event.h"
@@ -57,7 +58,7 @@ dAcBase_c::dAcBase_c()
if (s_Create_Scale) {
SetScale(*s_Create_Scale);
} else {
scale.set(1.0f, 1.0f, 1.0f);
mScale.set(1.0f, 1.0f, 1.0f);
}
if (s_Create_Parent != nullptr) {
@@ -77,8 +78,10 @@ dAcBase_c::dAcBase_c()
dAcBase_c::~dAcBase_c() {}
void dAcBase_c::setTempCreateParams(mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, s32 roomId, u32 params2,
dAcBase_c *parent, u8 subtype, s16 unkFlag, u8 viewClipIdx, ObjInfo *objInfo) {
void dAcBase_c::setTempCreateParams(
mVec3_c *pos, mAng3_c *rot, mVec3_c *scale, s32 roomId, u32 params2, dAcBase_c *parent, u8 subtype, s16 unkFlag,
u8 viewClipIdx, ObjInfo *objInfo
) {
s_Create_Position = pos;
s_Create_Rotation = rot;
s_Create_Scale = scale;
@@ -239,8 +242,9 @@ u32 dAcBase_c::itemDroppingAndGivingRelated(mVec3_c *spawnPos, int subtype) {
params2 = param2Copy | 0xFF000000;
// mAng3_c rot = {};
s16 rot = 0;
return SpecialItemDropMgr::giveSpecialDropItem(SpecialItemDropMgr::sInstance, param2Copy >> 0x18, roomid, spawnPos,
subtype, &rot, -1);
return SpecialItemDropMgr::giveSpecialDropItem(
SpecialItemDropMgr::sInstance, param2Copy >> 0x18, roomid, spawnPos, subtype, &rot, -1
);
}
// 8002cf90
@@ -356,8 +360,9 @@ s32 doAbs(s16 val) {
}
// Similar weirdness as the above function. Also, r29->31 are initted in the wrong order?
// 8002d290
bool dAcBase_c::getDistanceAndAngleToActor(dAcBase_c *actor, f32 distThresh, s16 yAngle, s16 xAngle, f32 *outDist,
s16 *outDiffAngleY, s16 *outDiffAngleX) {
bool dAcBase_c::getDistanceAndAngleToActor(
dAcBase_c *actor, f32 distThresh, s16 yAngle, s16 xAngle, f32 *outDist, s16 *outDiffAngleY, s16 *outDiffAngleX
) {
f32 distSquared = 3.402823e+38f;
s16 angleToActorY, angleToActorX;
bool isWithinRange = false;
@@ -371,7 +376,7 @@ bool dAcBase_c::getDistanceAndAngleToActor(dAcBase_c *actor, f32 distThresh, s16
angleToActorX = targetAngleX(&position, &actor->position);
if ((distSquared <= distThresh * distThresh) && (doAbs(s32(rotation.y.mVal - angleToActorY)) <= yAngle) &&
(doAbs(s32(rotation.x.mVal - angleToActorX)) <= xAngle)) {
(doAbs(s32(rotation.x.mVal - angleToActorX)) <= xAngle)) {
isWithinRange = true;
}
}
@@ -398,8 +403,9 @@ bool dAcBase_c::isWithinPlayerRadius(f32 radius) const {
}
// 8002d440
bool dAcBase_c::getDistanceAndAngleToPlayer(f32 distThresh, s16 yAngle, s16 xAngle, f32 *outDist, s16 *outDiffAngleY,
s16 *outDiffAngleX) {
bool dAcBase_c::getDistanceAndAngleToPlayer(
f32 distThresh, s16 yAngle, s16 xAngle, f32 *outDist, s16 *outDiffAngleY, s16 *outDiffAngleX
) {
return getDistanceAndAngleToActor(dAcPy_c::LINK, distThresh, yAngle, xAngle, outDist, outDiffAngleY, outDiffAngleX);
}
@@ -483,8 +489,10 @@ void dAcBase_c::changeLoadedEntitiesNoSet() {
// spawns GroupType2 (ACTOR)
// 8002d980
dAcBase_c *dAcBase_c::createActor(ProfileName actorId, u32 actorParams1, mVec3_c *actorPosition, mAng3_c *actorRotation,
mVec3_c *actorScale, u32 actorParams2, s32 actorRoomid, dBase_c *actorRef) {
dAcBase_c *dAcBase_c::createActor(
ProfileName actorId, u32 actorParams1, mVec3_c *actorPosition, mAng3_c *actorRotation, mVec3_c *actorScale,
u32 actorParams2, s32 actorRoomid, dBase_c *actorRef
) {
if (actorPosition == nullptr) {
actorPosition = &position;
}
@@ -494,7 +502,7 @@ dAcBase_c *dAcBase_c::createActor(ProfileName actorId, u32 actorParams1, mVec3_c
}
if (actorScale == nullptr) {
actorScale = &scale;
actorScale = &mScale;
}
if (actorRoomid == 63) {
@@ -503,16 +511,19 @@ dAcBase_c *dAcBase_c::createActor(ProfileName actorId, u32 actorParams1, mVec3_c
u32 newParams2 = actorParams2 != 0 ? getParams2_ignoreLower() : -1;
setTempCreateParams(actorPosition, actorRotation, actorScale, actorRoomid, newParams2, (dAcBase_c *)actorRef, 0, -1,
0xFF, nullptr);
setTempCreateParams(
actorPosition, actorRotation, actorScale, actorRoomid, newParams2, (dAcBase_c *)actorRef, 0, -1, 0xFF, nullptr
);
dBase_c *room = RoomManager::getRoom(roomid);
return (dAcBase_c *)dBase_c::createBase(actorId, room, actorParams1, ACTOR);
}
// spawns GroupType2 (STAGE)
// 8002da80
dAcBase_c *dAcBase_c::createActorStage(ProfileName actorId, u32 actorParams1, mVec3_c *actorPosition,
mAng3_c *actorRotation, mVec3_c *actorScale, u32 actorParams2, s32 actorRoomid, dBase_c *actorRef) {
dAcBase_c *dAcBase_c::createActorStage(
ProfileName actorId, u32 actorParams1, mVec3_c *actorPosition, mAng3_c *actorRotation, mVec3_c *actorScale,
u32 actorParams2, s32 actorRoomid, dBase_c *actorRef
) {
if (actorPosition == nullptr) {
actorPosition = &position;
}
@@ -522,7 +533,7 @@ dAcBase_c *dAcBase_c::createActorStage(ProfileName actorId, u32 actorParams1, mV
}
if (actorScale == nullptr) {
actorScale = &scale;
actorScale = &mScale;
}
if (actorRoomid == 63) {
@@ -531,8 +542,9 @@ dAcBase_c *dAcBase_c::createActorStage(ProfileName actorId, u32 actorParams1, mV
u32 newParams2 = actorParams2 != 0 ? getParams2_ignoreLower() : -1;
setTempCreateParams(actorPosition, actorRotation, actorScale, actorRoomid, newParams2, (dAcBase_c *)actorRef, 0, -1,
0xFF, nullptr);
setTempCreateParams(
actorPosition, actorRotation, actorScale, actorRoomid, newParams2, (dAcBase_c *)actorRef, 0, -1, 0xFF, nullptr
);
dBase_c *room = RoomManager::getRoom(roomid);
return (dAcBase_c *)dBase_c::createBase(actorId, room, actorParams1, STAGE);
}
+2 -3
View File
@@ -1,7 +1,6 @@
#include <d/a/d_a_player.h>
#include <d/a/obj/d_a_obj_fairy.h>
SPECIAL_ACTOR_PROFILE(OBJ_FAIRY, dAcObjFairy_c, fProfile::OBJ_FAIRY, 0x166, 0, 2);
STATE_DEFINE(dAcObjFairy_c, Wait);
@@ -52,7 +51,7 @@ int dAcObjFairy_c::draw() {
if (!isCuring()) {
static mQuat_c rot(0.0f, 0.0f, 0.0f, 10.0f);
drawShadow(mShadow, nullptr, worldMatrix, &rot, -1, -1, -1, -1, -1, position.y - field_0x4B0);
drawShadow(mShadow, nullptr, mWorldMtx, &rot, -1, -1, -1, -1, -1, position.y - field_0x4B0);
}
}
@@ -116,7 +115,7 @@ bool dAcObjFairy_c::shouldAvoidLink() const {
bool dAcObjFairy_c::isCuring() const {
return mStateMgr.isState(StateID_CureStart) || mStateMgr.isState(StateID_Cure) ||
mStateMgr.isState(StateID_CureEnd);
mStateMgr.isState(StateID_CureEnd);
}
bool dAcObjFairy_c::canTargetWithBugNet() const {
+38 -36
View File
@@ -1,6 +1,8 @@
#include <c/c_math.h>
#include <d/a/d_a_player.h>
#include <d/a/obj/d_a_obj_switch.h>
#include <d/col/bg/d_bg_s.h>
#include <d/col/bg/d_bg_w.h>
#include <s/s_Math.h>
#include <toBeSorted/sceneflag_manager.h>
@@ -27,10 +29,10 @@ void dAcOswMdlCallback_c::timingB(u32 nodeId, nw4r::g3d::WorldMtxManip *manip, n
static bool isPushableBlock(dAcBase_c *actor) {
return actor->isActorPlayer() || actor->profile_name == fProfile::OBJ_PUSH_BLOCK ||
actor->profile_name == fProfile::OBJ_KIBAKO;
actor->profile_name == fProfile::OBJ_KIBAKO;
}
void dAcOsw_c::interactCallback(void *unknown, dAcBase_c *actor, dAcObjBase_c *interactor) {
void dAcOsw_c::rideCallback(dBgW *unknown, dAcObjBase_c *actor, dAcObjBase_c *interactor) {
if (!isPushableBlock(interactor)) {
return;
}
@@ -38,20 +40,19 @@ void dAcOsw_c::interactCallback(void *unknown, dAcBase_c *actor, dAcObjBase_c *i
dAcOsw_c *sw = static_cast<dAcOsw_c *>(actor);
// halp
if (!(link == nullptr ||
((link->mActionFlags & 0x40000) == 0 &&
(((link->someFlags_0x340 & 0x800000) == 0 ||
if (!(link == nullptr || ((link->mActionFlags & 0x40000) == 0 &&
(((link->someFlags_0x340 & 0x800000) == 0 ||
((link->getCurrentCarriedActor() != nullptr &&
link->getCurrentCarriedActor()->mActorCarryInfo.testCarryFlag(0x04)))))))) {
link->getCurrentCarriedActor()->mActorCarryInfo.testCarryFlag(0x04)))))))) {
return;
}
if (interactor->mActorCarryInfo.isCarried != 1) {
if (link == nullptr || (link->mActionFlags & 0xC70852) == 0) {
if (!sw->someInteractCheck(link != nullptr)) {
bool needsOnFlag = sw->mOnSceneFlag < 0xFF &&
!SceneflagManager::sInstance->checkBoolFlag(sw->roomid, sw->mOnSceneFlag);
!SceneflagManager::sInstance->checkBoolFlag(sw->roomid, sw->mOnSceneFlag);
if (!needsOnFlag && sw->mObjRef.get() == nullptr && link != nullptr && sw->field_0x5F1 == 0 &&
sw->mStateMgr.isState(StateID_On)) {
sw->mStateMgr.isState(StateID_On)) {
link->field_0x360 |= 0x8000;
}
}
@@ -60,31 +61,32 @@ void dAcOsw_c::interactCallback(void *unknown, dAcBase_c *actor, dAcObjBase_c *i
}
}
extern "C" void fn_8033CE10();
bool dAcOsw_c::createHeap() {
nw4r::g3d::ResFile resFile = getOarcResFile(SWITCH_TYPES[mSwitchType]);
nw4r::g3d::ResMdl resMdl = resFile.GetResMdl(SWITCH_TYPES[mSwitchType]);
TRY_CREATE(mModel.create(resMdl, &heap_allocator, 0x20, 1, nullptr));
field_0x5E8 = scale.x *
(resMdl.GetResNode("base").mNode.ref().FLOAT_0x50 - resMdl.GetResNode("base").mNode.ref().FLOAT_0x44);
void *dbzData = getOarcDZB(SWITCH_TYPES[mSwitchType], SWITCH_TYPES[mSwitchType]);
void *plcData = getOarcPLC(SWITCH_TYPES[mSwitchType], SWITCH_TYPES[mSwitchType]);
scale.set(1.0f, 0.8f, 1.0f);
field_0x5E8 = mScale.x *
(resMdl.GetResNode("base").mNode.ref().FLOAT_0x50 - resMdl.GetResNode("base").mNode.ref().FLOAT_0x44);
cBgD_t *dbzData = (cBgD_t *)getOarcDZB(SWITCH_TYPES[mSwitchType], SWITCH_TYPES[mSwitchType]);
PLC *plcData = (PLC *)getOarcPLC(SWITCH_TYPES[mSwitchType], SWITCH_TYPES[mSwitchType]);
mScale.set(1.0f, 0.8f, 1.0f);
updateMatrix();
field_0x5B8.set(worldMatrix);
mModel.setLocalMtx(worldMatrix);
return !mCollision.create(dbzData, plcData, true, field_0x5B8, scale, fn_8033CE10);
field_0x5B8.set(mWorldMtx);
mModel.setLocalMtx(mWorldMtx);
bool set = mCollision.Set(dbzData, plcData, 1, &field_0x5B8, &mScale);
mCollision.SetCrrFunc(dBgS_MoveBGProc_TypicalRotY);
return !set;
}
int dAcOsw_c::actorCreate() {
mSwitchType = params & 0xF;
mOnSceneFlag = (params >> 0xE);
CREATE_ALLOCATOR(dAcOsw_c);
mCollision.interactFunc = interactCallback;
mCollision.SetRideCallback(rideCallback);
mModel.setCallback(&mButtonCtrl);
CollisionCheckContext::get()->registerActorBgCollision(mCollision, this);
dBgS::GetInstance()->Regist(&mCollision, this);
mOffSceneFlag = (params >> 0x4);
mCanBeSeen = ((params >> 0xC) & 3) == 0;
nw4r::g3d::ResMdl resMdl = mModel.getResMdl();
@@ -107,10 +109,10 @@ int dAcOsw_c::actorPostCreate() {
field_0x5A0.check(roomid, position, 0, 30.0f, 0.1f);
if (field_0x5A0.field_0x00 <= 0.0f) {
mHidden = true;
scale.set(0.0f, 0.0f, 0.0f);
mScale.set(0.0f, 0.0f, 0.0f);
} else {
mShown = true;
scale.set(1.0f, 1.0f, 1.0f);
mScale.set(1.0f, 1.0f, 1.0f);
}
}
@@ -124,7 +126,7 @@ int dAcOsw_c::actorPostCreate() {
}
}
} while (parent != nullptr);
mModel.setScale(scale);
mModel.setScale(mScale);
return SUCCEEDED;
}
@@ -148,7 +150,7 @@ int dAcOsw_c::actorExecute() {
if (mCanBeSeen) {
field_0x5A0.check(roomid, position, 0, 30.0f, 0.1f);
if (field_0x5A0.field_0x00 <= 0.0f) {
if (scale.x >= 1.0f) {
if (mScale.x >= 1.0f) {
if (!mHidden) {
fn_800298B0(PARTICLE_RESOURCE_ID_MAPPING_754_, &position, &rotation, 0, 0, 0, 0, 0);
playSound(0xC0B);
@@ -157,11 +159,11 @@ int dAcOsw_c::actorExecute() {
} else {
mHidden = false;
}
sLib::chase(&scale.x, 0.0f, 0.07f);
scale.y = scale.x;
scale.z = scale.x;
sLib::chase(&mScale.x, 0.0f, 0.07f);
mScale.y = mScale.x;
mScale.z = mScale.x;
} else {
if (scale.x <= 0.0f) {
if (mScale.x <= 0.0f) {
if (!mShown) {
fn_800298B0(PARTICLE_RESOURCE_ID_MAPPING_754_, &position, &rotation, 0, 0, 0, 0, 0);
playSound(0xC0A);
@@ -170,20 +172,20 @@ int dAcOsw_c::actorExecute() {
} else {
mShown = false;
}
sLib::chase(&scale.x, 1.0f, 0.07f);
scale.z = scale.x;
sLib::chase(&mScale.x, 1.0f, 0.07f);
mScale.z = mScale.x;
}
}
updateMatrix();
field_0x5B8.set(worldMatrix);
field_0x5B8.set(mWorldMtx);
mMtx_c tmp;
PSMTXTrans(tmp, 0.0f, mButtonCtrl.mElevation, 0.0f);
PSMTXConcat(field_0x5B8, tmp, field_0x5B8);
mModel.setScale(scale);
mModel.setLocalMtx(worldMatrix);
mModel.setScale(mScale);
mModel.setLocalMtx(mWorldMtx);
mModel.calc(false);
mCollision.execute();
mCollision.Move();
field_0x5F3 = 0;
mActivatedByPlayer = 0;
field_0x5F2 = field_0x5F1;
@@ -212,7 +214,7 @@ void dAcOsw_c::initializeState_OnWait() {
}
}
void dAcOsw_c::executeState_OnWait() {
sLib::chase(&scale.y, 0.8f, 0.12f);
sLib::chase(&mScale.y, 0.8f, 0.12f);
if (field_0x5F1 != 0) {
field_0x5F3 = 1;
}
@@ -282,7 +284,7 @@ void dAcOsw_c::executeState_Off() {
void dAcOsw_c::finalizeState_Off() {}
void dAcOsw_c::initializeState_None() {
scale.y = 0.8f;
mScale.y = 0.8f;
mButtonCtrl.mElevation = -20.0f;
}
void dAcOsw_c::executeState_None() {}
+5
View File
@@ -0,0 +1,5 @@
#include "d/col/bg/d_bg_pc.h"
bool dBgPc::getWtr() const {
return (m_code.code3 & 0x1F) == 0xC;
}
+9
View File
@@ -0,0 +1,9 @@
#include "d/col/bg/d_bg_plc.h"
void dBgPlc::setBase(void *pPlc) {
mBase = (PLC *)pPlc;
}
u32 dBgPlc::getGrpCode(int idx) const {
return getCode(idx)->code4;
}
File diff suppressed because it is too large Load Diff
+607
View File
@@ -0,0 +1,607 @@
#include "d/col/bg/d_bg_s_acch.h"
#include "d/a/d_a_player.h"
#include "d/col/bg/d_bg_s.h"
#include "d/col/c/c_bg_s_lin_chk.h"
#include "d/col/c/c_bg_w.h"
dBgS_AcchCir::dBgS_AcchCir() {
mWallRR = 0.0f;
mField_0x44 = 0.0f;
mWallH = 0.0f;
mWallR = 0.0f;
mWallHDirect = 0.0f;
mWallAngleY = 0.0f;
mFlags = 0;
}
dBgS_AcchCir::~dBgS_AcchCir() {}
bool dBgS_AcchCir::ChkWallHit() const {
bool ret = false;
if (mFlags & WALL_HIT) {
if (dBgS::GetInstance()->ChkPolySafe(*this)) {
ret = true;
}
}
return ret;
}
void dBgS_AcchCir::SetWallR(f32 wallR) {
mWallR = wallR;
}
void dBgS_AcchCir::SetWall(f32 wallH, f32 wallR) {
mWallH = wallH;
SetWallR(wallR);
}
dBgS_Acch::dBgS_Acch()
: mFlags(0), mpPos(nullptr), mpOldPos(nullptr), mSpeed(0.0f, 0.0f, 0.0f), mpSpeed(nullptr), mpAngle(nullptr),
mpShapeAngle(nullptr), mBgIndex(0), mField_0x094(0), mField_0x098(0), mpMyObj(nullptr), mTblSize(0),
mpAcchCir(nullptr), mField_0x0A8(0.0f), mField_0x0AC(0.0f), mGroundHeight(-1e9f), mField_0x0B4(120.0f),
mField_0x0C8(0.0f), mField_0x0CC(0.0f), mRoofHeight(1e9f), mField_0x0D4(1.0f), mField_0x0D8(0.0f),
mpOutPolyInfo(nullptr), mRoofH_0x0E0(0.0f), mGroundH_0x0E4(0.0f), mField_0x0E8(1e9f), mField_0x1D0(-1.0f),
mField_0x2F4(1000.0f), mField_0x390(0), mField_0x394(0) {
SetPolyPassChk(GetPolyPassChkInfo());
SetGrpPassChk(GetGrpPassChkInfo());
SetRoofNone();
mRoof.mField_0x7C = 1;
mField_0x398.set(0.0f, 0.0f, 0.0f);
mField_0x3A4.set(0.0f, 0.0f, 0.0f);
}
dBgS_Acch::~dBgS_Acch() {}
void dBgS_Acch::Set(
mVec3_c *pPos, mVec3_c *pOldPos, dAcObjBase_c *pObj, int tblSize, dBgS_AcchCir *pAccCir, mVec3_c *pSpeed,
mAng3_c *pAngle, mAng3_c *pShapeAngle
) {
mpPos = pPos;
mpOldPos = pOldPos;
mpMyObj = pObj;
mActorId = pObj->unique_ID;
mpSpeed = pSpeed;
if (pSpeed) {
mSpeed = *pSpeed;
} else {
mSpeed.set(0.0f, 0.0f, 0.0f);
}
mTblSize = tblSize;
mpAcchCir = pAccCir;
mpAngle = pAngle;
mpShapeAngle = pShapeAngle;
mGroundHeight = mpPos->y;
mField_0x1A8.Init();
}
void dBgS_Acch::Set(dAcObjBase_c *pObj, int tblSize, dBgS_AcchCir *pAcchCir) {
mTblSize = tblSize;
mpAcchCir = pAcchCir;
mpMyObj = pObj;
mActorId = pObj->getID();
mpPos = &pObj->GetPostion();
mpOldPos = &pObj->GetOldPosition();
mpSpeed = &pObj->GetVelocity();
if (mpSpeed) {
mSpeed = pObj->GetVelocity();
} else {
mSpeed.set(0.0f, 0.0f, 0.0f);
}
mpAngle = &pObj->GetAngle();
mpShapeAngle = &pObj->GetRotation();
}
bool dBgS_Acch::fn_8033f5b0(mVec3_c *pPos, mVec3_c *pOldPos, f32 height) {
*pOldPos = *pPos;
cBgS_LinChk line;
mVec3_c v1, v2;
v1 = *GetOldPos();
v1.y += height;
v2 = *pPos;
v2.y += height;
line.Set2(v1, v2, mActorId);
bool ret = false;
line.SetExtChk(*this);
if (dBgS::GetInstance()->LineCross(&line)) {
ret = true;
*pPos = line.mLin.mEnd;
cM3dGPla pla;
dBgS::GetInstance()->GetTriPla(line, &pla);
if (!cBgW_CheckBGround(pla.mNormal.y)) {
VEC3Add(pPos, pla.mNormal, pPos);
pPos->y -= height;
}
}
mpPos = pPos;
mpOldPos = pOldPos;
return ret;
}
void dBgS_Acch::GroundCheck(dBgS &bgs, bool param2) {
if (!(mFlags & GRND_NONE)) {
mVec3_c gnd_pos = *GetPos();
// This Ordering is weird
f32 temp = (mField_0x0B4 - mField_0x0A8) + mField_0x0AC;
if (mFlags & ACCH_FLAG_0x20000) {
if (temp <= 1.1f) {
temp = 1.1f;
}
}
gnd_pos.y += temp;
if (!(mFlags & GND_THIN_CELLING_OFF)) {
mVec3_c old_pos(*GetOldPos());
old_pos.y += 0.25f;
mVec3_c pos(*GetPos());
bgs.MoveBgCrrPos(mGnd, Chk_0x10000000(), &old_pos, nullptr, nullptr, false, false);
bgs.MoveBgCrrPos(mGnd, Chk_0x10000000(), &pos, nullptr, nullptr, false, false);
cBgS_LinChk line;
line.Set2(pos, old_pos, mActorId);
line.SetExtChk(*this);
line.mBackFlag = true;
if (!bgs.LineCross(&line)) {
dBgS_RoofChk roof;
roof.mActorId = mGnd.mActorId;
roof.SetPos(&pos);
f32 roof_height = bgs.RoofChk(&roof);
cM3dGPla plane;
if (roof_height != 1e9f) {
bgs.GetTriPla(roof, &plane);
if (gnd_pos.y > roof_height) {
gnd_pos.y = roof_height;
}
}
}
}
mField_0x0AC = 0.0f;
if (gnd_pos.y > mRoofHeight) {
gnd_pos.y = mRoofHeight + 0.25f;
}
if (gnd_pos.y < mpPos->y + mField_0x0E8 &&
mpPos->y + mField_0x0E8 < (mField_0x0B4 - mField_0x0A8) + mField_0x0AC + mpPos->y) {
gnd_pos.y = mpPos->y + mField_0x0E8;
}
mGnd.SetExtChk(*this);
mGnd.SetPos(&gnd_pos);
mGroundHeight = bgs.GroundCross(&mGnd);
Clr_0x10000000();
if (mGroundHeight != -1e9f) {
dBgS::GetInstance()->SetLightingCode(GetMyObj(), mGnd);
mField_0x0CC = mGroundHeight + mField_0x0A8;
if (mField_0x0CC > mField_0x0C8) {
mpPos->y = mField_0x0CC;
if (ChkClrSpeedY() && mpSpeed) {
mpSpeed->y = 0.0f;
}
bgs.GetTriPla(mGnd, &mPlane_0x0B8);
SetGroundFind();
if (param2) {
SetGroundHit();
}
Set_0x10000000();
if (!Chk_0x8000000() && !Chk_0x80000000()) {
Set_0x8000000();
bgs.RideCallBack(mGnd, GetMyObj());
}
if (!(Chk_0x4000000())) {
SetGroundLanding();
}
}
}
// UUUUUGH
if ((mFlags & ACCH_FLAG_0x4000000) && !(mFlags & GROUND_HIT)) {
SetGroundAway();
}
} else {
mGroundHeight = -1e9f;
}
}
void dBgS_Acch::RoofCheck(dBgS &bgs) {
if (mGroundHeight == -1e9f) {
return;
}
if (mFlags & LINE_DOWN && mField_0x0CC > mField_0x0D8 &&
(mGroundHeight <= mRoofHeight || cM3d_IsZero(mGroundHeight - mRoofHeight))) {
mpPos->y = (mGroundHeight + mRoofHeight) * 0.5f;
} else if (mpPos->y > mField_0x0D8 && mField_0x0D8 > mGroundHeight) {
mpPos->y = mField_0x0D8;
}
if (mFlags & ROOF_NONE) {
return;
}
if (mGroundHeight >= mRoofHeight) {
mRoof.SetExtChk(*this);
ClrRoofHit();
mVec3_c roof_pos = *GetPos();
roof_pos.y -= 0.25f;
mRoof.SetPos(&roof_pos);
mRoofHeight = bgs.RoofChk(&mRoof);
}
}
void dBgS_Acch::GroundRoofProc(dBgS &bgs, bool param2) {
mField_0x0D8 = 1e9f;
if (!(mFlags & ROOF_NONE)) {
mRoof.SetExtChk(*this);
ClrRoofHit();
mVec3_c roof_pos(*GetPos());
roof_pos.y -= 0.25f;
mRoof.SetPos(&roof_pos);
mRoofHeight = bgs.RoofChk(&mRoof);
if (mRoofHeight != 1e9f) {
if (mpPos->y + mField_0x0D4 > mRoofHeight) {
mField_0x0D8 = mRoofHeight - mField_0x0D4;
SetRoofHit();
} else if (mField_0x0C8 + mField_0x0D4 > mRoofHeight) {
mField_0x0D8 = mRoofHeight - mField_0x0D4;
SetRoofHit();
}
}
}
if (!(mFlags & GRND_NONE)) {
mFlags &= ~GROUND_FIND;
GroundCheck(bgs, param2);
RoofCheck(bgs);
} else {
if (mField_0x0D8 < mpPos->y) {
mpPos->y = mField_0x0D8;
}
mFlags &= ~ACCH_FLAG_0x10000000;
mGroundHeight = -1e9f;
}
}
void dBgS_Acch::LineCheck(dBgS &bgs) {
if (!(mFlags & ACCH_FLAG_0x20000000)) {
mFlags |= ACCH_FLAG_0x20000000;
dBgS_RoofChk roof;
roof.mActorId = mGnd.mActorId;
mVec3_c roof_pos = *GetOldPos();
roof_pos.y -= 0.25f;
roof.SetPos(&roof_pos);
mRoofH_0x0E0 = dBgS::GetInstance()->RoofChk(&roof);
dBgS_GndChk gnd;
gnd.mActorId = mGnd.mActorId;
mVec3_c gnd_pos = *GetOldPos();
gnd_pos.y += 0.25f;
gnd.SetPos(&gnd_pos);
mGroundH_0x0E4 = dBgS::GetInstance()->GroundCross(&gnd);
}
cBgS_LinChk line;
mField_0x0E8 = 1e9f;
int i = 0;
do {
mVec3_c old_pos = *GetOldPos();
mVec3_c pos = *GetPos();
f32 cirWallH = GetWallH(i);
if (mRoofH_0x0E0 - 0.25f < old_pos.y + cirWallH && mGroundH_0x0E4 + 0.25f > old_pos.y + cirWallH) {
cirWallH = (mRoofH_0x0E0 + mGroundH_0x0E4) * 0.5f - old_pos.y;
} else if (mRoofH_0x0E0 - 0.25f < old_pos.y + cirWallH) {
cirWallH = (mRoofH_0x0E0 - old_pos.y) - 0.25f;
} else if (mGroundH_0x0E4 + 0.25f > old_pos.y + cirWallH) {
cirWallH = (mGroundH_0x0E4 - old_pos.y) + 0.25f;
}
if (mField_0x0E8 > cirWallH) {
mField_0x0E8 = cirWallH;
}
old_pos.y += cirWallH;
pos.y += cirWallH;
if (GetSpeedY() < 0.0f) {
if (GetMyObj() != nullptr && GetMyObj()->isActorPlayer() &&
!static_cast<dAcPy_c *>(GetMyObj())->CheckPlayerFly() && ChkLink()) {
pos.y -= GetSpeedY();
}
}
if (old_pos.x != pos.x || old_pos.y != pos.y || old_pos.z != pos.z) {
line.Set2(old_pos, pos, mActorId);
if (ChkCirUnk0x8(i)) {
line.mPreGroundChk = true;
} else {
line.mPreGroundChk = false;
}
if (ChkCirUnk0x10(i)) {
line.mPreRoofChk = true;
} else {
line.mPreRoofChk = false;
}
line.SetExtChk(*this);
if (bgs.LineCross(&line)) {
*GetPos() = line.GetLinEnd();
OnLineCheckHit();
if (mpOutPolyInfo) {
*mpOutPolyInfo = line;
}
cM3dGPla plane;
bgs.GetTriPla(line, &plane);
if (!cBgW_CheckBGround(plane.mNormal.y)) {
mVec3_c *pPos = GetPos();
VEC3Add(*pPos, plane.mNormal, *pPos);
if (!cM3d_IsZero(
nw4r::math::FSqrt(plane.mNormal.x * plane.mNormal.x + plane.mNormal.z * plane.mNormal.z)
)) {
SetWallHDirect(i, GetPos()->y);
}
GetPos()->y -= GetWallH(i);
} else {
GetPos()->y -= 1.0f;
mFlags |= ACCH_FLAG_0x20000;
}
}
}
i++;
} while (i < GetTblSize());
}
extern "C" void *fn_80359C80(dBgS_SphChk *, cBgD_Vtx_t *, int, int, int, cM3dGPla *, void *);
void dBgS_Acch::SphCheck() {
f32 height = mField_0x1D0;
mSph.SetExtChk(*this);
mSph.mCallback = fn_80359C80;
if (height < 0.0f) {
height = 1e9f;
if (height > mField_0x0A8 && mField_0x0A8 > 0.0f) {
height = mField_0x0A8;
}
if (height > mField_0x0D4 && mField_0x0D4 > 1.0f) {
height = mField_0x0D4;
}
height *= 0.8f;
}
mSph.Set(mpPos, height);
mField_0x1A8.Init();
dBgS::GetInstance()->SphChk(&mSph, &mField_0x1A8);
mField_0x1A8.CalcPos(mpPos);
}
void dBgS_Acch::CrrPos(dBgS &bgs) {
if (!(mFlags & ACCH_FLAG_0x1)) {
bgs.MoveBgCrrPos(mGnd, ChkGroundHit(), mpPos, mpAngle, mpShapeAngle, false, false);
GroundCheckInit(bgs);
u32 prev = mField_0x394;
Init();
// Not in the mood to mess with these inlines lol
}
}
f32 dBgS_Acch::GetWallAllR() {
f32 ret = 0.0f;
int i = 0;
do {
if (ret < mpAcchCir[i].GetWallR()) {
ret = mpAcchCir[i].GetWallR();
}
++i;
} while (i < mTblSize);
return ret;
}
void dBgS_Acch::CalcWallBmdCyl() {
if (mTblSize <= 0) {
mWallCyl.Set(*mpPos, 0.0f, 0.0f);
} else {
f32 speed = GetSpeedY();
// TOD Stuff
f32 dvar8 = GetWallAllR();
f32 dvar9 = mpAcchCir->GetWallH();
f32 dvar10 = mpAcchCir->GetWallH();
// if (mTblSize >= 1) {
// for (int i = 0; i < mTblSize; i++) {
// f32 tmp = mpAcchCir[i].GetWallH();
// if (dvar9 > tmp) {
// dvar9 = mpAcchCir[i].GetWallH();
// }
// f32 tmp2 = mpAcchCir[i].GetWallH();
// if (dvar10 < tmp2) {
// dvar10 = mpAcchCir[i].GetWallH();
// }
// }
// }
mVec3_c xyz(*GetPos());
// TODO: Stuff
mWallCyl.Set(xyz, dvar8, dvar10 - dvar9);
}
}
void dBgS_Acch::SetGroundUpY(f32 param_0) {
mField_0x0AC = param_0 - mField_0x0A8;
mField_0x0A8 = param_0;
}
bool dBgS_Acch::fn_80340ca0(cBgS_PolyInfo &info) const {
int idx = 0;
if (ChkGndHit()) {
info.SetPolyInfo(mGnd);
return false;
}
if (ChkWallHit(&idx)) {
info.SetPolyInfo(mpAcchCir[idx]);
return false;
}
if (ChkRoofHit()) {
info.SetPolyInfo(mRoof);
return false;
}
return true;
}
void dBgS_Acch::Draw(dBgS &) {
// Name inferred from being called from (NPC?) draw functions.
// Maybe a debug visual?
}
void dBgS_Acch::SetMoveBGOnly() {
mFlags |= MOVE_BG_ONLY;
mWtr.OnMoveBGOnly();
}
void dBgS_Acch::ClrMoveBGOnly() {
mFlags &= ~MOVE_BG_ONLY;
mWtr.OffMoveBGOnly();
}
bool dBgS_Acch::ChkGndHit() const {
bool ret = false;
if (mFlags & GROUND_HIT) {
if (dBgS::GetInstance()->ChkPolySafe(mGnd)) {
ret = true;
}
}
return ret;
}
bool dBgS_Acch::ChkRoofHit() const {
bool ret = false;
if (mFlags & ROOF_HIT) {
if (dBgS::GetInstance()->ChkPolySafe(mRoof)) {
ret = true;
}
}
return ret;
}
bool dBgS_Acch::ChkWallHit(int *pOutIndex) const {
if (mFlags & WALL_HIT) {
int i = 0;
do {
if (mpAcchCir[i].ChkWallHit()) {
if (pOutIndex) {
*pOutIndex = i;
}
return true;
}
i++;
} while (i < mTblSize);
}
return false;
}
void dBgS_Acch::SetGndThinCellingOff() {
mFlags |= GND_THIN_CELLING_OFF;
}
void dBgS_Acch::ClrGndThinCellingOff() {
mFlags &= ~GND_THIN_CELLING_OFF;
}
void dBgS_Acch::Set_0x2000000() {
mFlags |= ACCH_FLAG_0x2000000;
}
void dBgS_Acch::Clr_0x2000000() {
mFlags &= ~ACCH_FLAG_0x2000000;
}
void dBgS_Acch::OnWallSort() {
mFlags |= WALL_SORT;
}
dBgS_AcchCir &dBgS_Acch::GetCir(int idx) {
return mpAcchCir[idx];
}
void dBgS_Acch::fn_80340f70(const mVec3_c *pVec) {
bool adjusted = false;
if (mField_0x398.x > pVec->x) {
mField_0x398.x = pVec->x;
adjusted = true;
} else if (mField_0x3A4.x < pVec->x) {
mField_0x3A4.x = pVec->x;
adjusted = true;
}
if (mField_0x398.z > pVec->z) {
mField_0x398.z = pVec->z;
adjusted = true;
} else if (mField_0x3A4.z < pVec->z) {
mField_0x3A4.z = pVec->z;
adjusted = true;
}
if (!adjusted && mField_0x394 > 0) {
mField_0x394--;
}
}
void dBgS_Acch::fn_80341000() {
mpPos->x += mField_0x398.x + mField_0x3A4.x;
mpPos->z += mField_0x398.z + mField_0x3A4.z;
}
dBgS_ObjAcch::dBgS_ObjAcch() {
SetObj();
}
dBgS_ObjAcch::~dBgS_ObjAcch() {}
dBgS_LinkAcch::dBgS_LinkAcch() {
SetLink();
}
dBgS_LinkAcch::~dBgS_LinkAcch() {}
dBgS_BombAcch::dBgS_BombAcch() {
SetBomb();
}
dBgS_BombAcch::~dBgS_BombAcch() {}
+20
View File
@@ -0,0 +1,20 @@
#include "d/col/bg/d_bg_s_chk.h"
dBgS_Chk::dBgS_Chk() {}
dBgS_Chk::~dBgS_Chk() {}
cBgS_PolyPassChk *dBgS_Chk::GetPolyPassChkInfo() {
return this;
}
cBgS_GrpPassChk *dBgS_Chk::GetGrpPassChkInfo() {
return this;
}
cBgS_GrpPassChk::cBgS_GrpPassChk() {}
cBgS_GrpPassChk::~cBgS_GrpPassChk() {}
cBgS_PolyPassChk::cBgS_PolyPassChk() {}
cBgS_PolyPassChk::~cBgS_PolyPassChk() {}
+93
View File
@@ -0,0 +1,93 @@
#include "d/col/bg/d_bg_s_gnd_chk.h"
#include "d/col/bg/d_bg_s.h"
dBgS_ObjGndChk dBgS_ObjGndChk::sInstance;
f32 dBgS_ObjGndChk::sGroundHeight;
dBgS_GndChk::dBgS_GndChk() {
SetPolyPassChk(GetPolyPassChkInfo());
SetGrpPassChk(GetGrpPassChkInfo());
}
dBgS_GndChk::~dBgS_GndChk() {}
void dBgS_GndChk::Set(const mVec3_c *pos, u32 *id) {
SetPos(pos);
SetActorID(id);
}
dBgS_LinkGndChk::dBgS_LinkGndChk() {
SetLink();
}
dBgS_LinkGndChk::~dBgS_LinkGndChk() {}
dBgS_ObjGndChk::dBgS_ObjGndChk() {
SetObj();
}
dBgS_ObjGndChk::~dBgS_ObjGndChk() {}
dBgS_ObjGndChk_Wtr::dBgS_ObjGndChk_Wtr() {
OffNormalGrp();
OnWaterGrp();
}
dBgS_ObjGndChk_Wtr::~dBgS_ObjGndChk_Wtr() {}
dBgS_ObjGndChk_All::~dBgS_ObjGndChk_All() {}
dBgS_CamGndChk::dBgS_CamGndChk() {
SetCam();
}
dBgS_CamGndChk::~dBgS_CamGndChk() {}
dBgS_ObjGndChk_All::dBgS_ObjGndChk_All() {
OnAll();
}
dBgS_CamGndChk_Wtr::dBgS_CamGndChk_Wtr() {
OnAll();
}
dBgS_CamGndChk_Wtr::~dBgS_CamGndChk_Wtr() {}
void dBgS_ObjGndChk::ClearInstance() {
sInstance.ClearPi();
}
bool dBgS_ObjGndChk::CheckPos(const mVec3_c *pPos) {
sInstance.SetPos(pPos);
sGroundHeight = dBgS::GetInstance()->GroundCross(&sInstance);
return sGroundHeight != -1e9f;
}
int dBgS_ObjGndChk::GetMaterial() {
return dBgS::GetInstance()->GetPolyAtt0(sInstance);
}
int dBgS_ObjGndChk::GetPolyAtt1() {
return dBgS::GetInstance()->GetPolyAtt1(sInstance);
}
bool dBgS_ObjGndChk::GetTriPlane(cM3dGPla *pPlane) {
return dBgS::GetInstance()->GetTriPla(sInstance, pPlane);
}
s32 dBgS_ObjGndChk::GetRoomID() {
return dBgS::GetInstance()->GetRoomId(sInstance);
}
bool dBgS_ObjGndChk::ChkMoveBG() {
return dBgS::GetInstance()->ChkMoveBG(sInstance, true);
}
int dBgS_ObjGndChk::GetLightingCode() {
return dBgS::GetInstance()->GetLightingCode(sInstance);
}
int dBgS_ObjGndChk::GetSpecialCode() {
return dBgS::GetInstance()->GetSpecialCode(sInstance);
}
+7
View File
@@ -0,0 +1,7 @@
#include "d/col/bg/d_bg_s_grp_pass_chk.h"
dBgS_GrpPassChk::dBgS_GrpPassChk() {
mGrp = 1;
}
dBgS_GrpPassChk::~dBgS_GrpPassChk() {}
+155
View File
@@ -0,0 +1,155 @@
#include "d/col/bg/d_bg_s_lin_chk.h"
#include "d/a/obj/d_a_obj_base.h"
#include "d/col/bg/d_bg_s.h"
#include "d/col/c/c_bg_w.h"
dBgS_ObjLinChk dBgS_ObjLinChk::sInstance;
dBgS_WtrLinChk dBgS_WtrLinChk::sInstance;
dBgS_LinChk::dBgS_LinChk() {
SetPolyPassChk(GetPolyPassChkInfo());
SetGrpPassChk(GetGrpPassChkInfo());
}
dBgS_LinChk::~dBgS_LinChk() {}
void dBgS_LinChk::Set(const mVec3_c *pStart, const mVec3_c *pEnd, const dAcObjBase_c *pObj) {
Set2(*pStart, *pEnd, pObj ? pObj->getID() : 0);
}
dBgS_CamLinChk::dBgS_CamLinChk() {
SetCam();
}
dBgS_CamLinChk::~dBgS_CamLinChk() {}
dBgS_CamLinChk_NorWtr::dBgS_CamLinChk_NorWtr() {
OnAll();
}
dBgS_CamLinChk_NorWtr::~dBgS_CamLinChk_NorWtr() {}
dBgS_ObjLinChk::dBgS_ObjLinChk() {
SetObj();
mPreRoofChk = false;
}
dBgS_ObjLinChk::~dBgS_ObjLinChk() {}
void dBgS_ObjLinChk::ClearInstance() {
sInstance.ClearPi();
}
void dBgS_ObjLinChk::SetEnd(const mVec3_c *pEnd) {
sInstance.mLin.mEnd = *pEnd;
}
bool dBgS_ObjLinChk::LineCross(mVec3_c const *pStart, mVec3_c const *pEnd, dAcObjBase_c const *pObj) {
sInstance.Set(pStart, pEnd, pObj);
return dBgS::GetInstance()->LineCross(&sInstance);
}
mAng dBgS_ObjLinChk::GetAngle() {
cM3dGPla plane;
GetTriPla(&plane);
return plane.GetAngleY();
}
bool dBgS_ObjLinChk::GetTriPla(cM3dGPla *pPlane) {
return dBgS::GetInstance()->GetTriPla(sInstance, pPlane);
}
int dBgS_ObjLinChk::GetMaterial() {
return dBgS::GetInstance()->GetPolyAtt0(sInstance);
}
bool dBgS_ObjLinChk::ChkMoveBG() {
return dBgS::GetInstance()->ChkMoveBG(sInstance, true);
}
bool dBgS_ObjLinChk::ChkGround() {
cM3dGPla plane;
GetTriPla(&plane);
return cBgW_CheckBGround(plane.mNormal.y);
}
bool dBgS_ObjLinChk::ChkWall() {
cM3dGPla plane;
GetTriPla(&plane);
return cBgW_CheckBWall(plane.mNormal.y);
}
bool dBgS_ObjLinChk::ChkRoof() {
cM3dGPla plane;
GetTriPla(&plane);
return cBgW_CheckBRoof(plane.mNormal.y);
}
dBgS_WtrLinChk::dBgS_WtrLinChk() {
OffFullGrp();
OnWaterGrp();
}
dBgS_WtrLinChk::~dBgS_WtrLinChk() {}
void dBgS_WtrLinChk::ClearInstance() {
sInstance.ClearPi();
}
void dBgS_WtrLinChk::SetEnd(const mVec3_c *pEnd) {
sInstance.mLin.mEnd = *pEnd;
}
bool dBgS_WtrLinChk::SetIsWater(mVec3_c const *pStart, mVec3_c const *pEnd, dAcObjBase_c const *pObj) {
sInstance.Set(pStart, pEnd, pObj);
bool ret = false;
if (dBgS::GetInstance()->LineCross(&sInstance)) {
if (dBgS::GetInstance()->GetSpecialCode(sInstance) == 0xC /* POLY_GROUND_WATER */) {
ret = true;
}
}
return ret;
}
dBgS_LinkLinChk::dBgS_LinkLinChk() {
SetLink();
}
dBgS_LinkLinChk::~dBgS_LinkLinChk() {}
dBgS_BombLinChk::dBgS_BombLinChk() {
SetBomb();
}
dBgS_BombLinChk::~dBgS_BombLinChk() {}
dBgS_ArrowLinChk::dBgS_ArrowLinChk() {
SetArrow();
}
dBgS_ArrowLinChk::~dBgS_ArrowLinChk() {}
dBgS_BeetleLinChk::dBgS_BeetleLinChk() {
SetBeetle();
}
dBgS_BeetleLinChk::~dBgS_BeetleLinChk() {}
dBgS_ClawshotLinChk::dBgS_ClawshotLinChk() {
SetClawshot();
}
dBgS_ClawshotLinChk::~dBgS_ClawshotLinChk() {}
dBgS_GustBellowsLinChk::dBgS_GustBellowsLinChk() {
SetBellows();
}
dBgS_GustBellowsLinChk::~dBgS_GustBellowsLinChk() {}
dBgS_WhipLinChk::dBgS_WhipLinChk() {
SetWhip();
}
dBgS_WhipLinChk::~dBgS_WhipLinChk() {}
+17
View File
@@ -0,0 +1,17 @@
#include "d/col/bg/d_bg_s_poly_pass_chk.h"
dBgS_PolyPassChk::dBgS_PolyPassChk() {
mObject = false;
mCamera = false;
mLink = false;
mArrow = false;
mBomb = false;
mWhip = false;
mBeetle = false;
mClawshot = false;
mUnderwaterRoof = false;
mBellows = false;
mField_0xE = false;
}
dBgS_PolyPassChk::~dBgS_PolyPassChk() {}
+44
View File
@@ -0,0 +1,44 @@
#include "d/col/bg/d_bg_s_roof_chk.h"
#include "d/col/bg/d_bg_s.h"
dBgS_ObjRoofChk dBgS_ObjRoofChk::sInstance;
f32 dBgS_ObjRoofChk::sRoofHeight;
dBgS_RoofChk::dBgS_RoofChk() {
mPos.set(0.0f, 0.0f, 0.0f);
mNowY = 0.0f;
mField_0x7C = 1;
mPosCopy.set(0.0f, 0.0f, 0.0f);
SetPolyPassChk(GetPolyPassChkInfo());
SetGrpPassChk(GetGrpPassChkInfo());
}
dBgS_RoofChk::~dBgS_RoofChk() {}
void dBgS_RoofChk::SetPos(mVec3_c const *pPos) {
mPos = *pPos;
}
dBgS_ObjRoofChk::dBgS_ObjRoofChk() {
SetObj();
}
dBgS_ObjRoofChk::~dBgS_ObjRoofChk() {}
void dBgS_ObjRoofChk::ClearInstance() {
sInstance.ClearPi();
}
bool dBgS_ObjRoofChk::CheckPos(const mVec3_c *pPos) {
sInstance.SetPos(pPos);
sRoofHeight = dBgS::GetInstance()->RoofChk(&sInstance);
return (sRoofHeight != 1e9f);
}
dBgS_LinkRoofChk::dBgS_LinkRoofChk() {
SetLink();
}
dBgS_LinkRoofChk::~dBgS_LinkRoofChk() {}
+23
View File
@@ -0,0 +1,23 @@
#include "d/col/bg/d_bg_s_sph_chk.h"
dBgS_SphChk::dBgS_SphChk() {
mField_0x80 = 0.0f;
mField_0x84.set(0.0f, 0.0f, 0.0f);
SetInfo(600, 0, 0);
mCallback = nullptr;
SetPolyPassChk(GetPolyPassChkInfo());
SetGrpPassChk(GetGrpPassChkInfo());
ClearPi();
}
dBgS_SphChk::~dBgS_SphChk() {}
dBgS_CamSphChk::dBgS_CamSphChk() {
SetCam();
}
dBgS_CamSphChk::~dBgS_CamSphChk() {}
+22
View File
@@ -0,0 +1,22 @@
#include "d\col\bg\d_bg_s_spl_grp_chk.h"
dBgS_SplGrpChk::dBgS_SplGrpChk() {
mGnd.set(0.0f, 0.0f, 0.0f);
mRoof = 1e9f;
mHeight = -1e9f;
mGroundH = -1e9f;
mFlags = 0;
SetPolyPassChk(GetPolyPassChkInfo());
SetGrpPassChk(GetGrpPassChkInfo());
OffNormalGrp();
}
dBgS_SplGrpChk::~dBgS_SplGrpChk() {}
void dBgS_SplGrpChk::Set(mVec3_c &gnd, f32 roof) {
mGnd = gnd;
mRoof = roof;
}
+36
View File
@@ -0,0 +1,36 @@
#include "d/col/bg/d_bg_s_wtr_chk.h"
#include "d/col/bg/d_bg_s.h"
dBgS_WtrChk dBgS_WtrChk::sInstance;
f32 dBgS_WtrChk::sWaterHeight;
dBgS_WtrChk::dBgS_WtrChk() {
OnWaterGrp();
}
dBgS_WtrChk::~dBgS_WtrChk() {}
void dBgS_WtrChk::ClearInstance() {
sInstance.ClearPi();
}
bool dBgS_WtrChk::CheckPos(const mVec3_c *pPos, bool b, f32 f1, f32 f2) {
mVec3_c water_pos;
water_pos.set(pPos->x, pPos->y + f2, pPos->z);
sInstance.Set(water_pos, pPos->y + f1);
if (dBgS::GetInstance()->WaterChk(&sInstance)) {
if (b && dBgS::GetInstance()->GetSpecialCode(sInstance) != 0xC /* POLY_GROUND_WATER */) {
// Other Liquid
} else {
sWaterHeight = sInstance.mGroundH;
return true;
}
}
return false;
}
int dBgS_WtrChk::GetMaterial() {
return dBgS::GetInstance()->GetPolyAtt0(sInstance);
}
+909
View File
@@ -0,0 +1,909 @@
#include "d/col/bg/d_bg_w.h"
#include "d/col/bg/d_bg_s.h"
#include "d/col/bg/d_bg_s_acch.h"
#include "d/col/bg/d_bg_w_kcol.h"
#include "d/col/c/c_bg_s_chk.h"
#include "d/col/c/c_bg_s_lin_chk.h"
#include "d/col/c/c_bg_s_shdw_draw.h"
#include "d/d_heap_alloc.h"
#include "toBeSorted/scgame.h"
bool cBgW::sLineCheck;
bool cBgW::sGndCheck;
bool cBgW::sWallCheck;
bool cBgW::sRoofCheck;
bool cBgW::sSplGrpCheck;
bool cBgW::sSphCheck;
mVec3_c dBgW::sWallCorrectPos(0.0f, 0.0f, 0.0f);
cBgW::cBgW()
: mpMdlMtx(nullptr), mTransVel(0.0f, 0.0f, 0.0f), mpScale(nullptr), mFlags(GLOBAL_e), mRootGroupIdx(-1),
mpTri(nullptr), mpRwg(nullptr), mpVtxTbl(nullptr), mpBgd(nullptr), mpBlk(nullptr), mpGrp(nullptr),
mpNodeTree(nullptr), mNeedsFullTransform(true) {
PSMTXIdentity(mInvMtx);
PSMTXIdentity(mMtx);
PSMTXIdentity(mMtxUnk);
}
cBgW::~cBgW() {
FreeArea();
}
void cBgW::FreeArea() {
if (mpTri) {
delete[] mpTri;
}
if (mpRwg) {
delete[] mpRwg;
}
if (mpNodeTree) {
delete[] mpNodeTree;
}
if (mpBlk) {
delete[] mpBlk;
}
if (mpGrp) {
delete[] mpGrp;
}
mpTri = nullptr;
mpRwg = nullptr;
mpNodeTree = nullptr;
mpBlk = nullptr;
mpGrp = nullptr;
mpVtxTbl = nullptr;
}
u32 cBgW::GetOldInvMtx(mMtx_c *m) {
return PSMTXInverse(mMtx, *m);
}
void cBgW::UpdateMtx() {
if (!mpMdlMtx) {
PSMTXIdentity(mInvMtx);
PSMTXIdentity(mMtx);
PSMTXIdentity(mMtxUnk);
} else {
PSMTXCopy(*mpMdlMtx, mInvMtx);
if (mpScale) {
mMtx_c scale;
PSMTXScale(scale, mpScale->x, mpScale->y, mpScale->z);
PSMTXConcat(mInvMtx, scale, mInvMtx);
}
PSMTXCopy(mInvMtx, mMtx);
PSMTXCopy(mInvMtx, mMtxUnk);
}
}
void cBgW::GlobalVtx() {
if (mpMdlMtx) {
if (!mNeedsFullTransform) {
int i = 0;
do {
nw4r::math::VEC3 *vtx = &mpVtxTbl[i];
VEC3Add(vtx, mTransVel, vtx);
i++;
} while (i < mpBgd->mVtxNum);
} else {
int i = 0;
do {
PSMTXMultVec(mInvMtx, mpBgd->mVtxTbl[i], mpVtxTbl[i]);
i++;
} while (i < mpBgd->mVtxNum);
}
}
}
bool cBgW::SetVtx() {
if (mFlags & NO_VTX_TBL_e) {
mpVtxTbl = nullptr;
} else if (mFlags & MOVE_BG_e) {
// Im not sure about this, but it works
mpVtxTbl = (cBgD_Vtx_t *)new (0x20) Vec[mpBgd->mVtxNum];
if (!mpVtxTbl) {
return true;
}
if (mFlags & CBGW_UNK_FLAG_40) {
int i = 0;
do {
mpVtxTbl[i].x = 0.0f;
mpVtxTbl[i].y = 0.0f;
mpVtxTbl[i].z = 0.0f;
i++;
} while (i < mpBgd->mVtxNum);
}
GlobalVtx();
} else {
mpVtxTbl = mpBgd->mVtxTbl;
}
return false;
}
void cBgW::CalcPlane() {
cBgD_Tri_t *tris = mpBgd->mTriTbl;
if (mpVtxTbl) {
if (!mNeedsFullTransform) {
int i = 0;
do {
mpTri[i].mD -= VEC3Dot(mpTri[i].mNormal, mTransVel);
i++;
} while (i < mpBgd->mTriNum);
} else {
int i = 0;
do {
mpTri[i].SetupFrom3Vtx(&mpVtxTbl[tris->mVtxIdx0], &mpVtxTbl[tris->mVtxIdx1], &mpVtxTbl[tris->mVtxIdx2]);
i++;
tris++;
} while (i < mpBgd->mTriNum);
}
}
}
bool cBgW::SetTri() {
mpTri = new cBgW_TriElm[mpBgd->mTriNum];
if (!mpTri) {
return true;
}
CalcPlane();
return false;
}
void cBgW::BlckConnect(u16 *pStartIdx, int *pPrevIdx, int idx) {
if (*pStartIdx == 0xFFFF) {
*pStartIdx = idx;
}
if (*pPrevIdx != 0xFFFF) {
mpRwg[*pPrevIdx].mNext = idx;
}
*pPrevIdx = idx;
mpRwg[idx].mNext = 0xFFFF;
}
void cBgW::ClassifyPlane() {
if (!mpVtxTbl) {
return;
}
int i = 0;
do {
int startIdx = mpBgd->mBlkTbl[i].field_0x0;
int endIdx;
if (i != mpBgd->mBlkNum - 1) {
endIdx = mpBgd->mBlkTbl[i + 1].field_0x0 - 1;
} else {
endIdx = mpBgd->mTriNum - 1;
}
mpBlk[i].mRoofIdx = 0xFFFF;
mpBlk[i].mWallIdx = 0xFFFF;
mpBlk[i].mGndIdx = 0xFFFF;
int blkRoofIdx, blkWallIdx, blkGndIdx;
blkRoofIdx = blkWallIdx = blkGndIdx = 0xFFFF;
for (int j = startIdx; j <= endIdx; j++) {
f32 norm_y = mpTri[j].GetNP()->y;
if (!cM3d_IsZero(mpTri[j].GetNP()->x) || !cM3d_IsZero(mpTri[j].GetNP()->y) ||
!cM3d_IsZero(mpTri[j].GetNP()->z)) {
if (cBgW_CheckBGround(norm_y)) {
BlckConnect(&mpBlk[i].mGndIdx, &blkGndIdx, j);
} else if (cBgW_CheckBRoof(norm_y)) {
if (!ChkRoofRegist()) {
BlckConnect(&mpBlk[i].mRoofIdx, &blkRoofIdx, j);
}
} else {
BlckConnect(&mpBlk[i].mWallIdx, &blkWallIdx, j);
}
}
}
i++;
} while (i < mpBgd->mBlkNum);
}
void cBgW::MakeBlckTransMinMax(mVec3_c *pMin, mVec3_c *pMax) {
VEC3Add(pMin, &mTransVel, pMin);
VEC3Add(pMax, &mTransVel, pMax);
}
void cBgW::MakeBlckMinMax(int vtxIdx, mVec3_c *pMin, mVec3_c *pMax) {
nw4r::math::VEC3 *vtx = &mpVtxTbl[vtxIdx];
if (pMin->x > vtx->x) {
pMin->x = vtx->x;
}
if (pMax->x < vtx->x) {
pMax->x = vtx->x;
}
if (pMin->y > vtx->y) {
pMin->y = vtx->y;
}
if (pMax->y < vtx->y) {
pMax->y = vtx->y;
}
if (pMin->z > vtx->z) {
pMin->z = vtx->z;
}
if (pMax->z < vtx->z) {
pMax->z = vtx->z;
}
}
int cBgW::GetPolyAtt0(const cBgS_PolyInfo &info) {
return 0;
}
void cBgW::MakeBlckBnd(int blkIdx, mVec3_c *pMin, mVec3_c *pMax) {
if (mNeedsFullTransform == 0) {
MakeBlckTransMinMax(pMin, pMax);
} else {
pMin->z = 1e9f;
pMin->y = 1e9f;
pMin->x = 1e9f;
pMax->z = -1e9f;
pMax->y = -1e9f;
pMax->x = -1e9f;
int max;
int start = mpBgd->mBlkTbl[blkIdx].field_0x0;
if (blkIdx != mpBgd->mBlkNum - 1) {
max = mpBgd->mBlkTbl[blkIdx + 1].field_0x0 - 1;
} else {
max = mpBgd->mTriNum - 1;
}
for (int i = start; i <= max; i++) {
MakeBlckMinMax(mpBgd->mTriTbl[i].mVtxIdx0, pMin, pMax);
MakeBlckMinMax(mpBgd->mTriTbl[i].mVtxIdx1, pMin, pMax);
MakeBlckMinMax(mpBgd->mTriTbl[i].mVtxIdx2, pMin, pMax);
}
pMin->x -= 1.0f;
pMin->y -= 1.0f;
pMin->z -= 1.0f;
pMax->x += 1.0f;
pMax->y += 1.0f;
pMax->z += 1.0f;
}
}
void cBgW::MakeNodeTreeRp(int treeIdx) {
cBgD_Tree_t *treeData = &mpBgd->mTreeTbl[treeIdx];
if (treeData->mFlag & 1) {
int child_idx = treeData->mId[0];
if (child_idx != 0xFFFF) {
mVec3_c *max = (mVec3_c *)mpNodeTree[treeIdx].GetMaxP();
mVec3_c *min = (mVec3_c *)mpNodeTree[treeIdx].GetMinP();
MakeBlckBnd(child_idx, min, max);
}
} else {
mpNodeTree[treeIdx].ClearForMinMax();
u16 *id = treeData->mId;
u16 *endIds = &id[8];
do {
if (id[0] != 0xFFFF) {
MakeNodeTreeRp(id[0]);
mpNodeTree[treeIdx].SetMinMax(*mpNodeTree[id[0]].GetMinP());
mpNodeTree[treeIdx].SetMinMax(*mpNodeTree[id[0]].GetMaxP());
}
id++;
} while (id < endIds);
}
}
void cBgW::MakeNodeTreeGrpRp(int grpIdx) {
if (mpBgd->mGrpTbl[grpIdx].mTreeIdx != 0xFFFF) {
MakeNodeTreeRp(mpBgd->mGrpTbl[grpIdx].mTreeIdx);
mpGrp[grpIdx].mAab.SetMin(*mpNodeTree[mpBgd->mGrpTbl[grpIdx].mTreeIdx].GetMinP());
mpGrp[grpIdx].mAab.SetMax(*mpNodeTree[mpBgd->mGrpTbl[grpIdx].mTreeIdx].GetMaxP());
}
s32 child_idx = mpBgd->mGrpTbl[grpIdx].mFirstChild;
while (child_idx != 0xFFFF) {
MakeNodeTreeGrpRp(child_idx);
mpGrp[grpIdx].mAab.SetMin(*mpGrp[child_idx].mAab.GetMinP());
mpGrp[grpIdx].mAab.SetMax(*mpGrp[child_idx].mAab.GetMaxP());
child_idx = mpBgd->mGrpTbl[child_idx].mNextSibling;
}
}
void cBgW::MakeNodeTree() {
if (mpVtxTbl == nullptr) {
int i = 0;
do {
if (mpBgd->mGrpTbl[i].mParent == 0xFFFF) {
mRootGroupIdx = i;
return;
}
i++;
} while (i < mpBgd->mGrpNum);
} else {
int i = 0;
do {
mpGrp[i].mAab.ClearForMinMax();
i++;
} while (i < mpBgd->mGrpNum);
i = 0;
do {
if (mpBgd->mGrpTbl[i].mParent == 0xFFFF) {
mRootGroupIdx = i;
MakeNodeTreeGrpRp(i);
break;
}
i++;
} while (i < mpBgd->mGrpNum);
i = 0;
do {
mpGrp[i].mAab.PlusR(1.0f);
i++;
} while (i < mpBgd->mGrpNum);
vt_0x3C();
}
}
bool cBgW::ChkMemoryError() {
if (!mpTri || !mpRwg || !mpBlk || !mpNodeTree || !mpGrp) {
return true;
}
return false;
}
bool cBgW::Set(cBgD_t *pbgd, PLC *pbgpc, u32 flags, mMtx_c *pMdlMtx, mVec3_c *pScale) {
mFlags = GLOBAL_e;
mpVtxTbl = nullptr;
if (pbgd == nullptr) {
return true;
}
mpPolyCodes.setBase(pbgpc);
mFlags = flags & 0xFF;
if (mFlags & GLOBAL_e) {
mpMdlMtx = nullptr;
mpScale = nullptr;
} else {
mpMdlMtx = pMdlMtx;
mpScale = pScale;
}
UpdateMtx();
mpBgd = pbgd;
if (SetVtx() || SetTri()) {
FreeArea();
return true;
}
if (mpRwg) {
delete[] mpRwg;
}
mpRwg = new cBgW_RwgElm[mpBgd->mTriNum];
if (mpRwg == nullptr) {
FreeArea();
return true;
}
if (mpBlk) {
delete[] mpBlk;
}
mpBlk = new cBgW_BlkElm[mpBgd->mBlkNum];
if (mpBlk == nullptr) {
FreeArea();
return true;
}
if (mpNodeTree) {
delete[] mpNodeTree;
}
mpNodeTree = new cBgW_NodeTree[mpBgd->mTreeNum];
if (mpNodeTree == nullptr) {
FreeArea();
return true;
}
if (mpGrp) {
delete[] mpGrp;
}
mpGrp = new cBgW_GrpElm[mpBgd->mGrpNum];
if (mpGrp == nullptr) {
FreeArea();
return true;
}
ClassifyPlane();
mNeedsFullTransform = 1;
MakeNodeTree();
return false;
}
bool cBgW::LineCheck(cBgS_LinChk *pLine) {
sLineCheck = false;
LineCheckGrpRp(pLine, mRootGroupIdx);
return sLineCheck;
}
void cBgW::LineCheckGrpRp(cBgS_LinChk *pLine, int grpIdx) {
cM3dGLin *pLin = &pLine->mLin;
if (!mpGrp[grpIdx].mAab.Cross(pLin)) {
return;
}
cBgD_Grp_t &grp = mpBgd->mGrpTbl[grpIdx];
if (grp.mTreeIdx != 0xFFFF) {
LineCheckRp(pLine, grp.mTreeIdx);
}
int childIdx = grp.mFirstChild;
while (childIdx != 0xFFFF) {
LineCheckGrpRp(pLine, childIdx);
childIdx = mpBgd->mGrpTbl[childIdx].mNextSibling;
}
}
void cBgW::LineCheckRp(cBgS_LinChk *pLine, int idx) {
// Why is the ordering like this here lol
cM3dGLin *pLin;
cBgW_BlkElm *blk;
u16 *id;
cBgD_Tree_t &tree = mpBgd->mTreeTbl[idx];
if (tree.mFlag & 1) {
blk = &mpBlk[tree.mId[0]];
if (blk->mWallIdx != 0xFFFF && !pLine->GetPreWallChk()) {
RwgLineCheck(blk->mWallIdx, pLine);
}
if (blk->mGndIdx != 0xFFFF && !pLine->GetPreGroundChk()) {
RwgLineCheck(blk->mGndIdx, pLine);
}
if (blk->mRoofIdx != 0xFFFF && !pLine->GetPreRoofChk()) {
RwgLineCheck(blk->mRoofIdx, pLine);
}
} else {
id = tree.mId;
do {
if (*id != 0xFFFF) {
pLin = &pLine->mLin;
if (mpNodeTree[*id].Cross(pLin)) {
LineCheckRp(pLine, *id);
}
}
id++;
} while (id < &tree.mId[8]);
}
}
void cBgW::RwgLineCheck(int polyIdx, cBgS_LinChk *pLine) {
// TODO
do {
cBgD_Tri_t *triTbl = mpBgd->mTriTbl;
cBgD_Vtx_t *vtxTbl = mpVtxTbl;
mVec3_c cross_pos;
if (cM3d_Cross_LinTri(
&pLine->mLin, &vtxTbl[triTbl[polyIdx].mVtxIdx0], &vtxTbl[triTbl[polyIdx].mVtxIdx1],
&vtxTbl[triTbl[polyIdx].mVtxIdx2], &mpTri[polyIdx], &cross_pos, pLine->ChkFrontFlag(),
pLine->ChkBackFlag()
)) {
dBgPc pc = *mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId);
if (!dBgWKCol::ChkPolyThrough(GetId(), &pc, pLine)
// && fn_803599c0(/* params */)
) {
pLine->mLin.mEnd = cross_pos;
pLine->SetPolyIndex(polyIdx);
sLineCheck = true;
}
}
polyIdx = mpRwg[polyIdx].mNext;
} while (polyIdx != 0xFFFF);
}
bool cBgW::GroundCross(cBgS_GndChk *pGnd) {
sGndCheck = false;
GroundCrossGrpRp(pGnd, mRootGroupIdx);
return sGndCheck;
}
void cBgW::GroundCrossGrpRp(cBgS_GndChk *, int) {}
void cBgW::GroundCrossRp(cBgS_GndChk *, int) {}
void cBgW::RwgGroundCheckGnd(u16, cBgS_GndChk *) {}
void cBgW::RwgGroundCheckWall(u16, cBgS_GndChk *) {}
void cBgW::Lock() {}
void cBgW::CopyOldMtx() {}
void cBgW::Move() {}
void cBgW::ShdwDraw(cBgS_ShdwDraw *) {}
void cBgW::ShdwDrawGrpRp(cBgS_ShdwDraw *, int) {}
void cBgW::ShdwDrawRp(cBgS_ShdwDraw *, int) {}
void cBgW::RwgShdwDraw(int, cBgS_ShdwDraw *) {}
const cM3dGAab *cBgW::GetBnd() const {
return &mpGrp[mRootGroupIdx].mAab;
}
bool cBgW::GetTriPnt(cBgS_PolyInfo const &info, mVec3_c *pA, mVec3_c *pB, mVec3_c *pC) const {
cBgD_Tri_t &tri = mpBgd->mTriTbl[info.GetPolyIndex()];
*pA = mpVtxTbl[tri.mVtxIdx0];
*pB = mpVtxTbl[tri.mVtxIdx1];
*pC = mpVtxTbl[tri.mVtxIdx2];
return true;
}
void cBgW::GetTopUnder(f32 *pOutTop, f32 *pOutUnder) const {
*pOutUnder = mpGrp[mRootGroupIdx].mAab.GetMinP()->y;
*pOutTop = mpGrp[mRootGroupIdx].mAab.GetMaxP()->y;
}
void cBgW::GetTriPla(int idx, cM3dGPla *pPla) {
*pPla = mpTri[idx];
}
void cBgW::GetTriPla(cBgS_PolyInfo const &info, cM3dGPla *pPla) const {
*pPla = mpTri[info.GetPolyIndex()];
}
u32 cBgW::GetGrpInf(cBgS_PolyInfo const &info) const {
return mpPolyCodes.getGrpCode(mpBgd->mTriTbl[info.GetPolyIndex()].mId);
}
s32 dBgW::GetGrpRoomIndex(cBgS_PolyInfo const &info) const {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getGrpRoomIdx();
}
s32 dBgW::GetExitId(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getExitId();
}
s32 dBgW::GetZTargetThrough(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getTargetThrough();
}
int dBgW::GetSpecialCode(cBgS_PolyInfo const &info) {
return GetSpecialCode(info.GetPolyIndex());
}
int dBgW::GetSpecialCode(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getSpecialCode();
}
int dBgW::GetCode0_0x30000000(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getCode0_0x30000000();
}
int dBgW::GetCode0_0x80000000(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getCode0_0x80000000();
}
u32 dBgW::GetPolyObjThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getObjThrough();
}
u32 dBgW::GetPolyCamThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getCamThrough();
}
u32 dBgW::GetPolyLinkThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getLinkThrough();
}
u32 dBgW::GetPolyArrowThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getArrowThrough();
}
u32 dBgW::GetPolySlingshotThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getSlingshotThrough();
}
u32 dBgW::GetPolyBeetleThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getBeetleThrough();
}
u32 dBgW::GetPolyClawshotThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getClawshotThrough();
}
u32 dBgW::GetPolyBombThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getBombThrough();
}
u32 dBgW::GetPolyWhipThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getWhipThrough();
}
u32 dBgW::GetUnderwaterRoofCode(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getUnderwaterRoof();
}
u32 dBgW::GetShdwThrough(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getShdwThrough();
}
int dBgW::GetLinkNo(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getLinkNo();
}
s32 dBgW::GetWallCode(cBgS_PolyInfo const &info) {
return GetWallAtt(info.GetPolyIndex());
}
u32 dBgW::GetWallAtt(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getWallCode();
}
int dBgW::GetPolyAtt0Material(cBgS_PolyInfo const &info) {
int att = mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getAtt0Code();
if (att >= 0x20) {
return att - 0x20;
}
return att;
}
int dBgW::GetPolyAtt1(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getAtt1Code();
}
int dBgW::GetGroundCode(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getGroundCode();
}
u32 dBgW::GetCode1_0x02000000(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getCode1_0x02000000();
}
u32 dBgW::GetCode1_0x04000000(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getCode1_0x04000000();
}
u32 dBgW::GetCode1_0x08000000(int polyIdx) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[polyIdx].mId)->getCode1_0x08000000();
}
u32 dBgW::GetLightingCode(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getLightingCode();
}
s32 dBgW::GetCamMoveBG(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getCamMoveBG();
}
s32 dBgW::GetRoomCamId(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getRoomCam();
}
s32 dBgW::GetRoomPathId(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getRoomPath();
}
s32 dBgW::GetRoomPathPntNo(cBgS_PolyInfo const &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getRoomPathPnt();
}
bool cBgW::ChkNotReady() const {
return mpVtxTbl == nullptr;
}
bool cBgW::ChkLock() const {
return mFlags & LOCK_e;
}
bool cBgW::ChkMoveBg() const {
return mFlags & MOVE_BG_e;
}
dBgW::dBgW() {
mpCrrFunc = nullptr;
mpRide_cb = nullptr;
mpArrowStick_cb = nullptr;
mpUnk_cb = nullptr;
mFlags = 0;
}
dBgW::~dBgW() {}
void dBgW::Move() {
OnMoveFlag();
cBgW::Move();
}
void dBgW::positionWallCorrect(dBgS_Acch *pAcch, f32 p1, cM3dGPla &pla, mVec3_c *pUpperPos, f32 p2) {
pAcch->SetWallHit();
if (p2 - 1.0f < 0.0f) {
return;
}
f32 dist = (p2 - 1.0f) * p1;
pUpperPos->x += dist * pla.mNormal.x;
pUpperPos->z += dist * pla.mNormal.z;
}
void dBgW::RwgWallCorrect(dBgS_Acch *, u16) {}
void dBgW::WallCorrectRp(dBgS_Acch *, int) {}
void dBgW::WallCorrectGrpRp(dBgS_Acch *, int) {}
bool dBgW::WallCorrect(dBgS_Acch *) {
// TODO - only satisfy warning
return false;
}
void dBgW::RwgWallCorrectSort(dBgS_Acch *, u16) {}
void dBgW::WallCorrectRpSort(dBgS_Acch *, int) {}
void dBgW::WallCorrectGrpRpSort(dBgS_Acch *, int) {}
bool dBgW::WallCorrectSort(dBgS_Acch *) {
// TODO - only satisfy warning
return false;
}
void dBgW::RwgRoofChk(u16, dBgS_RoofChk *, f32) {}
void dBgW::RwgRoofChkRoof(u16, dBgS_RoofChk *) {}
void dBgW::RwgRoofChkWall(u16, dBgS_RoofChk *) {}
void dBgW::RoofChkRp(dBgS_RoofChk *, int) {}
void dBgW::RoofChkGrpRp(dBgS_RoofChk *, int) {}
bool dBgW::RoofChk(dBgS_RoofChk *) {
// TODO - only satisfy warning
return false;
}
void dBgW::RwgSplGrpChk(u16, dBgS_SplGrpChk *) {}
void dBgW::SplGrpChkRp(dBgS_SplGrpChk *, int) {}
void dBgW::SplGrpChkGrpRp(dBgS_SplGrpChk *, int) {}
bool dBgW::SplGrpChk(dBgS_SplGrpChk *) {
// TODO - only satisfy warning
return false;
}
void dBgW::RwgCaptPoly(u16, dBgS_CaptPoly &) {}
void dBgW::CaptPolyRp(dBgS_CaptPoly &, int) {}
void dBgW::CaptPolyGrpRp(dBgS_CaptPoly &, int) {}
void dBgW::CaptPoly(dBgS_CaptPoly &) {}
void dBgW::RwgSphChk(u16, dBgS_SphChk *, void *) {}
void dBgW::SphChkRp(dBgS_SphChk *, void *, int) {}
void dBgW::SphChkGrpRp(dBgS_SphChk *, void *, int) {}
bool dBgW::SphChk(dBgS_SphChk *pSph, void *pV) {
sSphCheck = false;
SphChkRp(pSph, pV, mRootGroupIdx);
return sSphCheck;
}
void dBgW::CrrPos(cBgS_PolyInfo const &info, void *pObj, bool b, mVec3_c *pPos, mAng3_c *pAngle, mAng3_c *pShapeAngle) {
if (mpCrrFunc && static_cast<dAcObjBase_c *>(pObj)->baseProperties & dBase_c::BASE_PROP_0x4) {
mpCrrFunc(this, pObj, info, b, pPos, pAngle, pShapeAngle);
}
}
void dBgW::TransPos(
cBgS_PolyInfo const &info, void *pObj, bool b, mVec3_c *pPos, mAng3_c *pAngle, mAng3_c *pShapeAngle
) {
if (mpCrrFunc && static_cast<dAcObjBase_c *>(pObj)->baseProperties & dBase_c::BASE_PROP_0x4) {
mpCrrFunc(this, pObj, info, b, pPos, pAngle, pShapeAngle);
}
}
void dBgW::MatrixCrrPos(
cBgS_PolyInfo const &info, void *pObj, bool b, mVec3_c *pPos, mAng3_c *pAngle, mAng3_c *pShapeAngle
) {
CrrPos(info, pObj, b, pPos, pAngle, pShapeAngle);
}
void dBgW::CallRideCallback(dAcObjBase_c *p1, dAcObjBase_c *p2) {
if (mpRide_cb) {
mpRide_cb(this, p1, p2);
}
}
void dBgW::CallArrowStickCallback(dAcObjBase_c *p1, dAcObjBase_c *p2, mVec3_c &p3) {
if (mpArrowStick_cb) {
mpArrowStick_cb(this, p1, p2, p3);
}
}
bool dBgW::CallUnkCallback(dAcObjBase_c *p1, dAcObjBase_c *p2) {
if (mpUnk_cb) {
return mpUnk_cb(this, p1, p2);
}
return false;
}
void dBgW::OffMoveFlag() {
mFlags &= ~MOVE_BG_e;
}
u32 dBgW::ChkMoveFlag() const {
return mFlags & MOVE_BG_e;
}
void dBgW::vt_0x3C() {
cM3dGAab bnd = mpGrp[mRootGroupIdx].mAab;
GetPartition().fn_803391f0(&bnd);
}
bool dBgW::GetMapCode(int polyIdx, int *pOut) {
cBgS_PolyInfo info;
info.SetActorInfo(BG_ID_MAX, nullptr, 0);
info.SetPolyIndex(polyIdx);
int att0 = GetPolyAtt0(info);
int att1 = GetPolyAtt1(info);
bool target = GetZTargetThrough(info);
if (att0 >= 0x20) {
*pOut = dBgS::GetMapCode(att0 - 0x20, att1, target);
if (Chk0x24_0x20() && ScGame::currentSpawnInfo.trial == 1) {
*pOut = 0x1E;
}
return false;
} else {
return true;
}
}
bool dBgW::UpdateDraw(mAllocator_c *alloc) {
for (int i = 0; i < 0x1F; ++i) {
mMapRelated[i].mCount = 0;
}
for (int i = 0; i < mpBgd->mTriNum; i++) {
int idx = 0;
if (!GetMapCode(i, &idx)) {
mMapRelated[idx].mCount++;
}
}
for (int i = 0; i < 0x1F; ++i) {
if (mMapRelated[i].mCount > 0) {
mMapRelated[i].mpIdx = new (alloc) int[mMapRelated[i].mCount];
if (mMapRelated[i].mpIdx == nullptr) {
return false;
}
}
}
int local_cnt[0x1F];
for (int i = 0; i < 0x1F; i++) {
local_cnt[i] = 0;
}
for (int i = 0; i < mpBgd->mTriNum; i++) {
int idx = 0;
if (!GetMapCode(i, &idx)) {
mMapRelated[idx].mpIdx[local_cnt[idx]] = i;
local_cnt[idx]++;
}
}
return true;
}
int dBgW::GetPolyAtt0(const cBgS_PolyInfo &info) {
return mpPolyCodes.GetDBgPc(mpBgd->mTriTbl[info.GetPolyIndex()].mId)->getAtt0Code();
}
bool dBgW::GetIsDraw(int idx) {
return mMapRelated[idx].mCount > 0;
}
void dBgW::DrawOnMap(int idx, bool) {}
+103
View File
@@ -0,0 +1,103 @@
#include "d/col/bg/d_bg_w_base.h"
#include "d/col/bg/d_bg_s.h"
dBgW_Base::dBgW_Base() {
ClrDBgWBase();
}
dBgW_Base::~dBgW_Base() {
if (ChkUsed()) {
dBgS::GetInstance()->Release(this);
}
if (GetRegistId() != BG_ID_MAX) {
dBgS::GetInstance()->UnRegist(this);
}
ClrDBgWBase();
}
void dBgW_Base::ClrDBgWBase() {
// Regswap?
mRoomId = 0xFF;
mPriority = 2;
field_0x2E = 0xFF;
// A set to 0 is required. I think 0x24 may be flags, so an unset then set?
field_0x24 = 0;
field_0x24 = 4;
mRegistId = BG_ID_MAX;
field_0x2F = 0xFF;
mDiffShapeAngleY = 0;
mOldShapeAngleY = 0;
SetPushPullCallback(nullptr);
ClearMap();
field_0x20 = 0;
field_0x22 = 0xFFFF;
}
bool dBgW_Base::ChkMemoryError() {
return false;
}
void dBgW_Base::CallRideCallback(dAcObjBase_c *, dAcObjBase_c *) {
// No Call
}
void dBgW_Base::CallArrowStickCallback(dAcObjBase_c *, dAcObjBase_c *, mVec3_c &) {
// No Call
}
bool dBgW_Base::CallUnkCallback(dAcObjBase_c *, dAcObjBase_c *) {
return false;
}
void dBgW_Base::CalcDiffShapeAngleY(s16 shapeAngleY) {
mDiffShapeAngleY = shapeAngleY - mOldShapeAngleY;
mOldShapeAngleY = shapeAngleY;
}
void dBgW_Base::SetOldShapeAngleY(s16 oldShapeAngleY) {
mOldShapeAngleY = oldShapeAngleY;
}
bool dBgW_Base::InitMapStuff(mAllocator_c *pAllocator) {
ClearMap();
return UpdateDraw(pAllocator) != false;
}
bool dBgW_Base::fn_8034AD70() const {
u8 val = mField_0x18.field_0x00;
if (val == 0 || val == 2) {
return true;
}
return false;
}
bool dBgW_Base::fn_8034ADA0() const {
return mField_0x18.field_0x00 <= 1;
}
bool dBgW_Base::UpdateDraw(mAllocator_c * /* unused */) {
ClearMap();
return true;
}
void dBgW_Base::RegistBg(int id) {
mRegistId = id;
}
void dBgW_Base::UnRegistBg() {
mRegistId = BG_ID_MAX;
}
bool dBgW_Base::ChkReady() const {
if (mRegistId == BG_ID_MAX || ChkNotReady()) {
return false;
}
return true;
}
void dBgW_Base::Set0x2F(u8 val) {
field_0x2F = val;
}
+676
View File
@@ -0,0 +1,676 @@
#include "d/col/bg/d_bg_w_kcol.h"
#include "d/col/bg/d_bg_s.h"
#include "d/col/bg/d_bg_s_gnd_chk.h"
#include "d/col/bg/d_bg_s_lin_chk.h"
#include "toBeSorted/scgame.h"
char STAGE_FS_A[] = "D201";
char STAGE_FS_B[] = "D201_1";
char STAGE_SSH[] = "D301";
dBgWKCol::dBgWKCol() : mpKCHead(nullptr) {
mNumPrism = 0;
mpTri = 0;
}
dBgWKCol::~dBgWKCol() {
mpKCHead = nullptr;
mpTri = 0;
}
void dBgWKCol::initKCollision(void *pFile) {
KCol_Header *pHeader = (KCol_Header *)pFile;
pkcdata *pData = (pkcdata *)pFile;
pData->mpPositionData = (mVec3_c *)((u32)pFile + pHeader->pos_data_offset);
pData->mpNormalData = (mVec3_c *)((u32)pFile + pHeader->nrm_data_offset);
pData->mpPrismData = (KC_PrismData *)((u32)pFile + pHeader->prism_data_offset);
pData->mpBlockData = (u32 *)((u32)pFile + pHeader->block_data_offset);
}
void dBgWKCol::Set(void *pKcl, void *pPlc) {
ClrDBgWBase();
mpKCHead = (pkcdata *)pKcl;
mNumPrism = ((u32)mpKCHead->mpBlockData - (u32)mpKCHead->mpPrismData) / sizeof(KC_PrismData) + 1;
mCode.setBase(pPlc);
// Z,Y,X important?
f32 z = mpKCHead->mAreaMinPos.z;
f32 y = mpKCHead->mAreaMinPos.y;
f32 x = mpKCHead->mAreaMinPos.x;
u32 mz = mpKCHead->mAreaWidthMaskZ;
u32 my = mpKCHead->mAreaWidthMaskY;
u32 mx = mpKCHead->mAreaWidthMaskX;
mBnd.Set(mVec3_c(x, y, z), mVec3_c(x + ~mx, y + ~my, z + ~mz));
vt_0x3C();
mAreaWidthMaskX = ~mpKCHead->mAreaWidthMaskX;
mAreaWidthMaskY = ~mpKCHead->mAreaWidthMaskY;
mAreaWidthMaskZ = ~mpKCHead->mAreaWidthMaskZ;
}
void dBgWKCol::GetTriNrm(KC_PrismData *pd, mVec3_c **ppTriNrm) const {
*ppTriNrm = GetTriNrm(pd);
}
bool dBgWKCol::ChkNotReady() const {
return mpKCHead == nullptr;
}
bool dBgWKCol::ChkLock() const {
return false;
}
bool dBgWKCol::ChkMoveBg() const {
return false;
}
u32 dBgWKCol::ChkMoveFlag() const {
return 0;
}
void dBgWKCol::GetTriPla(cBgS_PolyInfo const &polyInf, cM3dGPla *plane) const {
mVec3_c *pFaceNrm;
KC_PrismData *pPrismData = GetPrismData(polyInf.GetPolyIndex());
GetTriNrm(pPrismData, &pFaceNrm);
mVec3_c *pPos = GetTriPos(pPrismData);
plane->mNormal = *pFaceNrm;
plane->mD = -VEC3Dot(plane->mNormal, *pPos);
}
bool dBgWKCol::GetTriPnt(cBgS_PolyInfo const &polyInf, mVec3_c *v1, mVec3_c *v2, mVec3_c *v3) const {
return GetTriPnt(polyInf.GetPolyIndex(), v1, v2, v3);
}
bool dBgWKCol::GetTriPnt(int poly_index, mVec3_c *v1, mVec3_c *v2, mVec3_c *v3) const {
return GetTriPnt(GetPrismData(poly_index), v1, v2, v3);
}
bool dBgWKCol::GetTriPnt(KC_PrismData const *pPrism, mVec3_c *v1, mVec3_c *v2, mVec3_c *v3) const {
*v1 = *GetTriPos(pPrism);
mVec3_c face_nrm1, face_nrm2;
mVec3_c *pFaceNrm = GetTriNrm(pPrism);
mVec3_c *pEdgeNrm3 = GetEdgeNrm3(pPrism);
VEC3Cross(face_nrm1, pFaceNrm, GetEdgeNrm1(pPrism));
f32 mag = VEC3Dot(face_nrm1, pEdgeNrm3);
if (cM3d_IsZero(mag)) {
return false;
}
mag = pPrism->mHeight / mag;
VEC3Scale(face_nrm1, face_nrm1, mag);
VEC3Add(v3, face_nrm1, v1);
VEC3Cross(face_nrm2, GetEdgeNrm2(pPrism), pFaceNrm);
mag = VEC3Dot(face_nrm1, pEdgeNrm3);
if (cM3d_IsZero(mag)) {
return false;
}
mag = pPrism->mHeight / mag;
VEC3Scale(face_nrm2, face_nrm2, mag);
VEC3Add(v2, face_nrm2, v1);
return true;
}
const cM3dGAab *dBgWKCol::GetBnd() const {
return &mBnd;
}
u32 dBgWKCol::GetGrpInf(cBgS_PolyInfo const &pi) const {
return mCode.getGrpCode(GetPrismData(pi.GetPolyIndex())->mAttribute);
}
void dBgWKCol::OffMoveFlag() {}
bool dBgWKCol::ChkPolyThrough(int id, dBgPc *, cBgS_Chk *) {
// TODO - false return to satisify warnings
return false;
}
bool dBgWKCol::ChkPolyThroughGnd(int id, dBgPc *, cBgS_Chk *) {
// TODO - false return to satisify warnings
return false;
}
void dBgWKCol::vt_0x3C() {
mPartitionInfo.fn_803391f0(&mBnd);
}
bool dBgWKCol::LineCheck(cBgS_LinChk *pLine) {
mVec3_c diff;
VEC3Sub(diff, pLine->mLin.GetStartP(), pLine->mLin.GetEndP());
f32 mag = PSVECMag(diff);
if (mag < 500.0f) {
int tmp0 = (int)(mag * 0.002f) + 1;
f32 tmp1 = mag / (tmp0 + 1);
VEC3Scale(diff, diff, tmp1 / mag);
}
// TODO Later lmao
}
bool dBgWKCol::GroundCross(cBgS_GndChk *pGnd) {
// TODO - false return to satisify warnings
return false;
}
void dBgWKCol::ShdwDraw(cBgS_ShdwDraw *pShdw) {}
void dBgWKCol::CaptPoly(dBgS_CaptPoly &capt) {}
bool dBgWKCol::WallCorrectSort(dBgS_Acch *pAcch) {
// TODO - false return to satisify warnings
return false;
}
bool dBgWKCol::WallCorrect(dBgS_Acch *pAcch) {
// TODO - false return to satisify warnings
return false;
}
bool dBgWKCol::RoofChk(dBgS_RoofChk *pRoof) {
// TODO - false return to satisify warnings
return false;
}
bool dBgWKCol::SplGrpChk(dBgS_SplGrpChk *) {
// TODO - false return to satisify warnings
return false;
}
bool dBgWKCol::SphChk(dBgS_SphChk *, void *) {
// TODO - false return to satisify warnings
return false;
}
void dBgWKCol::GetTopUnder(f32 *pOutTop, f32 *pOutUnder) const {
f32 pos = mpKCHead->mAreaMinPos.y;
*pOutUnder = pos;
*pOutTop = pos + mAreaWidthMaskY;
}
s32 dBgWKCol::GetGrpRoomIndex(cBgS_PolyInfo const &info) const {
return GetPolyCode(info.GetPolyIndex())->getGrpRoomIdx();
}
s32 dBgWKCol::GetExitId(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getExitId();
}
s32 dBgWKCol::GetZTargetThrough(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getTargetThrough();
}
int dBgWKCol::GetSpecialCode(cBgS_PolyInfo const &info) {
return GetSpecialCode(info.GetPolyIndex());
}
int dBgWKCol::GetSpecialCode(int polyIdx) {
return GetPolyCode(polyIdx)->getSpecialCode();
}
int dBgWKCol::GetCode0_0x30000000(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getCode0_0x30000000();
}
int dBgWKCol::GetCode0_0x80000000(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getCode0_0x80000000();
}
u32 dBgWKCol::GetPolyObjThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getObjThrough();
}
u32 dBgWKCol::GetPolyCamThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getCamThrough();
}
u32 dBgWKCol::GetPolyLinkThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getLinkThrough();
}
u32 dBgWKCol::GetPolyArrowThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getArrowThrough();
}
u32 dBgWKCol::GetPolySlingshotThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getSlingshotThrough();
}
u32 dBgWKCol::GetPolyBeetleThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getBeetleThrough();
}
u32 dBgWKCol::GetPolyClawshotThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getClawshotThrough();
}
u32 dBgWKCol::GetPolyBombThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getBombThrough();
}
u32 dBgWKCol::GetPolyWhipThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getWhipThrough();
}
u32 dBgWKCol::GetUnderwaterRoofCode(int polyIdx) {
return GetPolyCode(polyIdx)->getUnderwaterRoof();
}
u32 dBgWKCol::GetShdwThrough(int polyIdx) {
return GetPolyCode(polyIdx)->getShdwThrough();
}
int dBgWKCol::GetLinkNo(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getLinkNo();
}
s32 dBgWKCol::GetWallCode(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getWallCode();
}
int dBgWKCol::GetPolyAtt0Material(cBgS_PolyInfo const &info) {
int mat = GetPolyCode(info.GetPolyIndex())->getAtt0Code();
if (mat >= 0x20) {
mat -= 0x20;
}
return mat;
}
int dBgWKCol::GetPolyAtt1(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getAtt1Code();
}
int dBgWKCol::GetGroundCode(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getGroundCode();
}
u32 dBgWKCol::GetCode1_0x02000000(int polyIdx) {
return GetPolyCode(polyIdx)->getCode1_0x02000000();
}
u32 dBgWKCol::GetCode1_0x04000000(int polyIdx) {
return GetPolyCode(polyIdx)->getCode1_0x04000000();
}
u32 dBgWKCol::GetCode1_0x08000000(int polyIdx) {
return GetPolyCode(polyIdx)->getCode1_0x08000000();
}
u32 dBgWKCol::GetLightingCode(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getLightingCode();
}
s32 dBgWKCol::GetCamMoveBG(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getCamMoveBG();
}
s32 dBgWKCol::GetRoomCamId(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getRoomCam();
}
s32 dBgWKCol::GetRoomPathId(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getRoomPath();
}
s32 dBgWKCol::GetRoomPathPntNo(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getRoomPathPnt();
}
void dBgWKCol::CrrPos(cBgS_PolyInfo const &, void *, bool, mVec3_c *, mAng3_c *, mAng3_c *) {}
void dBgWKCol::TransPos(cBgS_PolyInfo const &, void *, bool, mVec3_c *, mAng3_c *, mAng3_c *) {}
void dBgWKCol::MatrixCrrPos(cBgS_PolyInfo const &, void *, bool, mVec3_c *, mAng3_c *, mAng3_c *) {}
int dBgWKCol::GetMapCode(KC_PrismData *prism, int *pOut) {
cBgS_PolyInfo info;
if (mpKCHead->mpNormalData[prism->mFaceNrmIdx].y <= 0.f) {
return true;
}
if (mpTri != nullptr) {
int idx = GetPrismIdx(prism);
KC_Tri &tri = mpTri[idx];
mVec3_c a, b, c;
VEC3Sub(a, tri.mB, tri.mA);
VEC3Sub(b, tri.mC, tri.mB);
VEC3Sub(c, tri.mA, tri.mC);
if (cM3d_IsZero(VEC3Len(a))) {
return true;
}
if (cM3d_IsZero(VEC3Len(b))) {
return true;
}
if (cM3d_IsZero(VEC3Len(c))) {
return true;
}
}
info.SetPolyIndex(prism - mpKCHead->mpPrismData);
int att0 = GetPolyAtt0(info);
int att1 = GetPolyAtt1(info);
bool target = GetZTargetThrough(info);
if (att0 >= 0x20) {
*pOut = dBgS::GetMapCode(att0 - 0x20, att1, target);
return false;
} else {
return true;
}
}
bool dBgWKCol::UpdateDraw(mAllocator_c *alloc) {
// TODO
// To Generate Weak Ct and Dt of KC_Tri
mpTri = new (alloc) KC_Tri[mNumPrism];
if (mpTri == nullptr) {
return false;
}
KC_PrismData *startPrism = mpKCHead->mpPrismData;
KC_PrismData *currPrism = startPrism + 1;
mBnd.ClearForMinMax();
do {
//
mVec3_c a, b, c;
if (!GetTriPnt(currPrism, &a, &b, &c)) {
a = mpKCHead->mpPositionData[currPrism->mPosIdx];
b = a;
c = a;
}
int idx = currPrism - mpKCHead->mpPrismData;
mpTri[idx].mA = a;
mpTri[idx].mB = b;
mpTri[idx].mC = c;
mBnd.SetMinMax(a);
mBnd.SetMinMax(b);
mBnd.SetMinMax(c);
currPrism++;
} while (currPrism < (KC_PrismData *)mpKCHead->mpBlockData);
mBnd.PlusR(1.0f);
vt_0x3C();
ClearMapCount();
currPrism = mpKCHead->mpPrismData + 1;
do {
int mapCode = 0;
if (!GetMapCode(currPrism, &mapCode)) {
mMapRelated[mapCode].mCount++;
}
currPrism++;
} while (currPrism < (KC_PrismData *)mpKCHead->mpBlockData);
for (int i = 0; i < 0x1F; i++) {
if (mMapRelated[i].mCount > 0) {
mMapRelated[i].mpIdx = new (alloc) int[mMapRelated[i].mCount];
if (mMapRelated[i].mpIdx == nullptr) {
return false;
}
}
}
int local_cnt[0x1F];
for (int i = 0; i < 0x1F; i++) {
local_cnt[i] = 0;
}
currPrism = mpKCHead->mpPrismData + 1;
do {
int mapCode = 0;
if (!GetMapCode(currPrism, &mapCode)) {
mMapRelated[mapCode].mpIdx[local_cnt[mapCode]] = currPrism - mpKCHead->mpPrismData;
local_cnt[mapCode]++;
}
currPrism++;
} while (currPrism < (KC_PrismData *)mpKCHead->mpBlockData);
return true;
}
int dBgWKCol::GetPolyAtt0(cBgS_PolyInfo const &info) {
return GetPolyCode(info.GetPolyIndex())->getAtt0Code();
}
bool dBgWKCol::GetIsDraw(int idx) {
if (mMapRelated[idx].mCount <= 0) {
return false;
}
return mpTri != nullptr;
}
void dBgWKCol::DrawMapSection(int idx, f32 yPos, f32 upper, f32 lower) {
int all = mMapRelated[idx].mCount;
int count = 0;
for (int i = 0; i < all; i++) {
KC_Tri &tri = mpTri[mMapRelated[idx].mpIdx[i]];
if (
// If Tri height is not above or below the limits
!((tri.mA.y > upper) && (tri.mB.y > upper) && (tri.mC.y > upper)) &&
!((tri.mA.y < lower) && (tri.mB.y < lower) && (tri.mC.y < lower))) {
count++;
}
};
GXBegin(GX_TRIANGLES, GX_VTXFMT0, count * 3);
for (int i = 0; i < all; i++) {
KC_Tri &tri = mpTri[mMapRelated[idx].mpIdx[i]];
if (
// If Tri height is not above or below the limits
!((tri.mA.y > upper) && (tri.mB.y > upper) && (tri.mC.y > upper)) &&
!((tri.mA.y < lower) && (tri.mB.y < lower) && (tri.mC.y < lower)))
{
f32 BAx = tri.mB.x - tri.mA.x;
f32 CBx = tri.mC.x - tri.mB.x;
f32 ACx = tri.mA.x - tri.mC.x;
f32 BAz = tri.mB.z - tri.mA.z;
f32 CBz = tri.mC.z - tri.mB.z;
f32 ACz = tri.mA.z - tri.mC.z;
f32 tmp0 = nw4r::math::FSqrt(BAx * BAx + BAz * BAz);
f32 tmp1 = nw4r::math::FSqrt(CBx * CBx + CBz * CBz);
f32 tmp2 = nw4r::math::FSqrt(ACx * ACx + ACz * ACz);
tmp0 = cM3d_IsZero(tmp0) ? 0.0f : 10.0f / tmp0;
tmp1 = cM3d_IsZero(tmp1) ? 0.0f : 10.0f / tmp1;
tmp2 = cM3d_IsZero(tmp2) ? 0.0f : 10.0f / tmp2;
f32 t0x = BAx * tmp0;
f32 t0z = BAz * tmp0;
f32 t1z = CBz * tmp1;
f32 t1x = CBx * tmp1;
f32 t2x = ACx * tmp2;
f32 t2z = ACz * tmp2;
f32 x0 = t2x + (tri.mA.x - t0x);
f32 z0 = t2z + (tri.mA.z - t0z);
f32 x2 = t0x + (tri.mB.x - t1x);
f32 z2 = t0z + (tri.mB.z - t1z);
f32 x1 = t1x + (tri.mC.x - t2x);
f32 z1 = t1z + (tri.mC.z - t2z);
GXPosition3f32(x0, yPos, z0);
GXPosition3f32(x1, yPos, z1);
GXPosition3f32(x2, yPos, z2);
}
}
}
void dBgWKCol::DrawOnMap(int idx, bool param2) {
// uhhhhhh
if (!GetIsDraw(idx)) {
return;
}
if (param2) {
// FS Room 9 /* Spiral Staircase */
if (GetRoomId() == 9 && (ScGame::isCurrentStage(STAGE_FS_A) || ScGame::isCurrentStage(STAGE_FS_B))) {
int all = mMapRelated[idx].mCount;
mVec3_c AB, CA, BC;
mVec3_c v0, v1, v2;
// Pass 1
int count = 0;
for (int i = 0; i < all; i++) {
KC_Tri &tri = mpTri[mMapRelated[idx].mpIdx[i]];
if (!((tri.mA.y < -550.0f) && (tri.mB.y < -550.0f) && (tri.mC.y < -550.0f))) {
count++;
}
}
GXBegin(GX_TRIANGLES, GX_VTXFMT0, count * 3);
for (int i = 0; i < all; i++) {
KC_Tri &tri = mpTri[mMapRelated[idx].mpIdx[i]];
if (!((tri.mA.y < -550.0f) && (tri.mB.y < -550.0f) && (tri.mC.y < -550.0f))) {
VEC3Sub(AB, tri.mB, tri.mA);
VEC3Sub(CA, tri.mA, tri.mC);
VEC3Sub(BC, tri.mC, tri.mB);
f32 len0 = VEC3Len(AB);
f32 len1 = VEC3Len(CA);
f32 len2 = VEC3Len(BC);
VEC3Scale(AB, AB, 10.0f / len0);
VEC3Scale(CA, CA, 10.0f / len1);
VEC3Scale(BC, BC, 10.0f / len2);
VEC3Sub(v0, tri.mA, AB);
VEC3Sub(v1, tri.mC, CA);
VEC3Sub(v2, tri.mB, BC);
VEC3Add(v0, v0, CA);
VEC3Add(v1, v1, BC);
VEC3Add(v2, v2, AB);
GXPosition3f32(v0.x, v0.y, v0.z);
GXPosition3f32(v1.x, v1.y, v1.z);
GXPosition3f32(v2.x, v2.y, v2.z);
}
}
// Pass 2
count = 0;
for (int i = 0; i < all; i++) {
KC_Tri &tri = mpTri[mMapRelated[idx].mpIdx[i]];
if (!((tri.mA.y > -550.0f) && (tri.mB.y > -550.0f) && (tri.mC.y > -550.0f))) {
count++;
}
}
GXBegin(GX_TRIANGLES, GX_VTXFMT0, count * 3);
for (int i = 0; i < all; i++) {
KC_Tri &tri = mpTri[mMapRelated[idx].mpIdx[i]];
if (!((tri.mA.y > -550.0f) && (tri.mB.y > -550.0f) && (tri.mC.y > -550.0f))) {
VEC3Sub(AB, tri.mB, tri.mA);
VEC3Sub(CA, tri.mA, tri.mC);
VEC3Sub(BC, tri.mC, tri.mB);
f32 len0 = VEC3Len(AB);
f32 len1 = VEC3Len(CA);
f32 len2 = VEC3Len(BC);
VEC3Scale(AB, AB, 10.0f / len0);
VEC3Scale(CA, CA, 10.0f / len1);
VEC3Scale(BC, BC, 10.0f / len2);
VEC3Sub(v0, tri.mA, AB);
VEC3Sub(v2, tri.mB, BC);
VEC3Sub(v1, tri.mC, CA);
VEC3Add(v0, v0, CA);
VEC3Add(v1, v1, BC);
VEC3Add(v2, v2, AB);
// v0.y = (v0.y + 6500.0f) * 0.1680672f - 6500.0f;
// v1.y = (v1.y + 6500.0f) * 0.1680672f - 6500.0f;
// v2.y = (v2.y + 6500.0f) * 0.1680672f - 6500.0f;
GXPosition3f32(v0.x, (v0.y + 6500.0f) * 0.1680672f - 6500.0f, v0.z);
GXPosition3f32(v1.x, (v1.y + 6500.0f) * 0.1680672f - 6500.0f, v1.z);
GXPosition3f32(v2.x, (v2.y + 6500.0f) * 0.1680672f - 6500.0f, v2.z);
// GXPosition3f32(v0.x, v0.y, v0.z);
// GXPosition3f32(v1.x, v1.y, v1.z);
// GXPosition3f32(v2.x, v2.y, v2.z);
}
}
}
// Normal
else {
int all = mMapRelated[idx].mCount;
GXBegin(GX_TRIANGLES, GX_VTXFMT0, all * 3);
for (int i = 0; i < all; i++) {
KC_Tri &tri = mpTri[mMapRelated[idx].mpIdx[i]];
mVec3_c AB, CA, BC;
mVec3_c v0, v1, v2;
VEC3Sub(AB, tri.mB, tri.mA);
VEC3Sub(CA, tri.mA, tri.mC);
VEC3Sub(BC, tri.mC, tri.mB);
f32 len0 = VEC3Len(AB);
f32 len1 = VEC3Len(CA);
f32 len2 = VEC3Len(BC);
VEC3Scale(AB, AB, 10.0f / len0);
VEC3Scale(CA, CA, 10.0f / len1);
VEC3Scale(BC, BC, 10.0f / len2);
VEC3Sub(v0, tri.mA, AB);
VEC3Sub(v1, tri.mC, CA);
VEC3Sub(v2, tri.mB, BC);
VEC3Add(v0, v0, CA);
VEC3Add(v1, v1, BC);
VEC3Add(v2, v2, AB);
GXPosition3f32(v0.x, v0.y, v0.z);
GXPosition3f32(v1.x, v1.y, v1.z);
GXPosition3f32(v2.x, v2.y, v2.z);
}
}
}
// Sections
else {
const cM3dGAab *bnd = GetBnd();
f32 yPos = (bnd->GetMinP()->y + bnd->GetMaxP()->y) * 0.5f;
// Sandship
if (GetRoomId() == 15 && ScGame::isCurrentStage(STAGE_SSH)) {
yPos = 0.0f;
}
if (idx == 0x12 /* Abyss `Common/tex/naraku.bti`)*/) {
yPos -= 1.0f;
}
if (ScGame::isCurrentStage(STAGE_FS_A) || ScGame::isCurrentStage(STAGE_FS_B)) {
int room = GetRoomId();
/* FS Room 9 - Spiral Staircse */
if (room == 9) {
DrawMapSection(idx, yPos, 1e9f, -550.0f);
DrawMapSection(idx, -6000.0f, -550.0f, -1e9f);
return;
}
/* FS Room 6 - Bridges */
if (room == 6) {
DrawMapSection(idx, yPos, 1e9f, -5500.0f);
DrawMapSection(idx, -6000.0f, -550.0f, -1e9f);
return;
}
}
DrawMapSection(idx, yPos, 1e9f, -1e9f);
}
}
int dBgWKCol::GetPrismIdx(const KC_PrismData *pPrismData) {
return (pPrismData - mpKCHead->mpPrismData);
}
+204
View File
@@ -0,0 +1,204 @@
#include "d/col/bg/d_bg_w_sv.h"
#include "d/col/c/c_bg_s_chk.h"
dBgWSv::dBgWSv() {
mpVtx = nullptr;
}
dBgWSv::~dBgWSv() {}
bool dBgWSv::Set(cBgD_t *pDzb, PLC *pPlc, u32 p3, bool p4) {
u32 flags = 0;
if (p4) {
flags |= 0x10;
}
if (cBgW::Set(pDzb, pPlc, flags | 99, nullptr, nullptr)) {
return true;
}
mField_0x214 = p3;
if (p3 & 1) {
return false;
}
mpVtx = (nw4r::math::VEC3 *)new Vec[mpBgd->mVtxNum];
return mpVtx == nullptr;
}
void dBgWSv::CopyBackVtx() {
if (!mpVtx || !mpVtxTbl) {
return;
}
for (int i = 0; i < mpBgd->mVtxNum; i++) {
mpVtx[i] = mpVtxTbl[i];
}
}
bool dBgWSv::CrrPosWork(mVec3_c *pPos, int vtx0, int vtx1, int vtx2) {
mVec3_c tmp0, tmp1;
tmp0.x = mpVtx[vtx1].x - mpVtx[vtx0].x;
tmp0.y = mpVtx[vtx1].y - mpVtx[vtx0].y;
tmp0.z = mpVtx[vtx1].z - mpVtx[vtx0].z;
tmp1.x = mpVtx[vtx2].x - mpVtx[vtx0].x;
tmp1.y = mpVtx[vtx2].y - mpVtx[vtx0].y;
tmp1.z = mpVtx[vtx2].z - mpVtx[vtx0].z;
if (cM3d_IsZero(tmp0.z) || cM3d_IsZero(tmp1.z)) {
return true;
}
f32 tmp2 = tmp0.x - (tmp0.z * (tmp1.x / tmp1.z));
f32 tmp3 = tmp1.x - (tmp1.z * (tmp0.x / tmp0.z));
if (cM3d_IsZero(tmp2) || cM3d_IsZero(tmp3)) {
return true;
}
pPos->x -= mpVtx[vtx0].x;
pPos->z -= mpVtx[vtx0].z;
mVec3_c tmp4;
mVec3_c tmp5;
f32 tmp6 = (pPos->x - (pPos->z * (tmp1.x / tmp1.z))) / tmp2;
f32 tmp7 = (pPos->x - (pPos->z * (tmp0.x / tmp0.z))) / tmp3;
tmp4.x = mpVtxTbl[vtx1].x - mpVtxTbl[vtx0].x;
tmp4.z = mpVtxTbl[vtx1].z - mpVtxTbl[vtx0].z;
tmp5.x = mpVtxTbl[vtx2].x - mpVtxTbl[vtx0].x;
tmp5.z = mpVtxTbl[vtx2].z - mpVtxTbl[vtx0].z;
pPos->x = (tmp6 * tmp4.x) + (tmp7 * tmp5.x);
pPos->z = (tmp6 * tmp4.z) + (tmp7 * tmp5.z);
pPos->x += mpVtxTbl[vtx0].x;
pPos->z += mpVtxTbl[vtx0].z;
return false;
}
void dBgWSv::CrrPos(
cBgS_PolyInfo const &info, void *pObj, bool b, mVec3_c *pPos, mAng3_c *pAngle, mAng3_c *pShapeAngle
) {
if (mField_0x214 & 1) {
return;
}
if (!b) {
return;
}
int idx = info.GetPolyIndex();
cBgD_Tri_t *tri = mpBgd->mTriTbl;
u32 vtx0 = tri[idx].mVtxIdx0;
u32 vtx1 = tri[idx].mVtxIdx1;
u32 vtx2 = tri[idx].mVtxIdx2;
if (CrrPosWork(pPos, vtx0, vtx1, vtx2) && CrrPosWork(pPos, vtx1, vtx2, vtx0)) {
CrrPosWork(pPos, vtx2, vtx0, vtx1);
}
}
bool dBgWSv::TransPosWork(mVec3_c *pPos, int vtx0, int vtx1, int vtx2) {
mVec3_c tmp0;
mVec3_c tmp1;
tmp0.x = mpVtx[vtx1].x - mpVtx[vtx0].x;
tmp0.y = mpVtx[vtx1].y - mpVtx[vtx0].y;
tmp0.z = mpVtx[vtx1].z - mpVtx[vtx0].z;
tmp1.x = mpVtx[vtx2].x - mpVtx[vtx0].x;
tmp1.y = mpVtx[vtx2].y - mpVtx[vtx0].y;
tmp1.z = mpVtx[vtx2].z - mpVtx[vtx0].z;
if (cM3d_IsZero(tmp0.z) || cM3d_IsZero(tmp1.z)) {
return true;
}
f32 tmp2 = tmp0.x - (tmp0.z * (tmp1.x / tmp1.z));
f32 tmp3 = tmp1.x - (tmp1.z * (tmp0.x / tmp0.z));
if (cM3d_IsZero(tmp2) || cM3d_IsZero(tmp3)) {
return true;
}
f32 tmp4 = pPos->x - mpVtx[vtx0].x;
f32 tmp5 = pPos->z - mpVtx[vtx0].z;
f32 tmp6 = (tmp4 - (tmp5 * (tmp1.x / tmp1.z))) / tmp2;
f32 tmp7 = (tmp4 - (tmp5 * (tmp0.x / tmp0.z))) / tmp3;
if (tmp6 < 0.0f || tmp6 > 1.0f || tmp7 < 0.0f || tmp7 > 1.0f) {
return true;
}
mVec3_c tmp8;
mVec3_c tmp9;
tmp8.x = mpVtxTbl[vtx1].x - mpVtxTbl[vtx0].x;
tmp8.y = mpVtxTbl[vtx1].y - mpVtxTbl[vtx0].y;
tmp8.z = mpVtxTbl[vtx1].z - mpVtxTbl[vtx0].z;
tmp9.x = mpVtxTbl[vtx2].x - mpVtxTbl[vtx0].x;
tmp9.y = mpVtxTbl[vtx2].y - mpVtxTbl[vtx0].y;
tmp9.z = mpVtxTbl[vtx2].z - mpVtxTbl[vtx0].z;
pPos->x = (tmp6 * tmp8.x) + (tmp7 * tmp9.x);
pPos->y = (tmp6 * tmp8.y) + (tmp7 * tmp9.y);
pPos->z = (tmp6 * tmp8.z) + (tmp7 * tmp9.z);
pPos->x += mpVtxTbl[vtx0].x;
pPos->y += mpVtxTbl[vtx0].y;
pPos->z += mpVtxTbl[vtx0].z;
return false;
}
void dBgWSv::TransPos(
cBgS_PolyInfo const &info, void *pObj, bool b, mVec3_c *pPos, mAng3_c *pAngle, mAng3_c *pShapeAngle
) {
if (mField_0x214 & 1) {
return;
}
if (!b) {
return;
}
int idx = info.GetPolyIndex();
cBgD_Tri_t *tri = mpBgd->mTriTbl;
u32 vtx0 = tri[idx].mVtxIdx0;
u32 vtx1 = tri[idx].mVtxIdx1;
u32 vtx2 = tri[idx].mVtxIdx2;
if (TransPosWork(pPos, vtx0, vtx1, vtx2) && TransPosWork(pPos, vtx1, vtx2, vtx0)) {
TransPosWork(pPos, vtx2, vtx0, vtx1);
}
}
void dBgWSv::MatrixCrrPos(
cBgS_PolyInfo const &info, void *pObj, bool b, mVec3_c *pPos, mAng3_c *pAngle, mAng3_c *pShapeAngle
) {}
void dBgWSv::ApplyMtx(mMtx_c *pMtx) {
mpMdlMtx = pMtx;
ClrNoCalcVtx();
UpdateMtx();
GlobalVtx();
mpMdlMtx = nullptr;
UpdateMtx();
SetNoCalcVtx();
}
void dBgWSv::SetTriHeight(int idx, f32 y) {
mpVtxTbl[idx].y = y;
}
nw4r::math::VEC3 *dBgWSv::GetTri(int idx) {
return &mpVtxTbl[idx];
}
+328
View File
@@ -0,0 +1,328 @@
#include "d/col/bg/d_bg_w_time.h"
#include "d/col/bg/d_bg_s_lin_chk.h"
#include "d/col/bg/d_bg_s_sph_chk.h"
#include "d/col/bg/d_bg_w.h"
dBgWTime::dBgWTime() {}
dBgWTime::~dBgWTime() {}
void dBgWTime::GetTopUnder(f32 *pOutTop, f32 *pOutUnder) const {
f32 height = mCyl.mHeight;
f32 posY = mCyl.GetC().y;
*pOutTop = posY + height;
*pOutUnder = posY;
}
bool dBgWTime::ChkNotReady() const {
return false;
}
bool dBgWTime::ChkLock() const {
return false;
}
bool dBgWTime::ChkMoveBg() const {
return true;
}
u32 dBgWTime::ChkMoveFlag() const {
return false;
}
void dBgWTime::GetTriPla(cBgS_PolyInfo const &info, cM3dGPla *pPla) const {
*pPla = info.GetPlane();
}
// part of c_m3d but idk a name for it yet
extern "C" bool fn_803350A0(const cM3dGPla *, mMtx_c *);
bool dBgWTime::GetTriPnt(cBgS_PolyInfo const &info, mVec3_c *pA, mVec3_c *pB, mVec3_c *pC) const {
mMtx_c mtx;
if (!fn_803350A0(&info.GetPlane(), &mtx)) {
return false;
}
pA->set(0.f, 0.f, 1.f);
pB->set(1.f, 0.f, -1.f);
pC->set(-1.f, 0.f, -1.f);
PSMTXMultVec(mtx, *pA, *pA);
PSMTXMultVec(mtx, *pB, *pB);
PSMTXMultVec(mtx, *pC, *pC);
*pA += info.GetField0x20();
*pB += info.GetField0x20();
*pC += info.GetField0x20();
return true;
}
const cM3dGAab *dBgWTime::GetBnd() const {
return &mBnd;
}
u32 dBgWTime::GetGrpInf(cBgS_PolyInfo const &) const {
return 0;
}
void dBgWTime::OffMoveFlag() {}
void dBgWTime::vt_0x3C() {
mPartitionInfo.fn_803391f0(&mBnd);
}
bool dBgWTime::LineCheck(cBgS_LinChk *pLine) {
mVec3_c &linStart = (mVec3_c &)pLine->GetLinStart();
mVec3_c &linEnd = (mVec3_c &)pLine->GetLinEnd();
bool bStart = mCyl.Cross(linStart);
bool bEnd = mCyl.Cross(linEnd);
if (bStart && bEnd) {
return false;
}
if (!bStart && bEnd) {
if (!pLine->ChkFrontFlag()) {
return false;
}
} else if (bStart && !bEnd) {
if (!pLine->ChkBackFlag()) {
return false;
}
} else if (!pLine->ChkFrontFlag()) {
return false;
}
cM3dGLin lin;
lin.Set(linStart, linEnd);
mVec3_c vec0;
mVec3_c vec1;
if (!cM3d_Cross_CylLin(&mCyl, &lin, vec0, vec1)) {
return false;
}
if (!fn_803537a0(&vec0, pLine)) {
return false;
}
fn_80353a00(pLine, &vec0);
linEnd = vec0;
return true;
}
bool dBgWTime::GroundCross(cBgS_GndChk *) {
return false;
}
void dBgWTime::ShdwDraw(cBgS_ShdwDraw *) {}
void dBgWTime::CaptPoly(dBgS_CaptPoly &) {}
bool dBgWTime::WallCorrect(dBgS_Acch *) {
// TODO - false return to satisfy warning
return false;
}
bool dBgWTime::WallCorrectSort(dBgS_Acch *pAcch) {
return WallCorrect(pAcch);
}
bool dBgWTime::RoofChk(dBgS_RoofChk *) {
return false;
}
bool dBgWTime::SplGrpChk(dBgS_SplGrpChk *) {
return false;
}
bool dBgWTime::SphChk(dBgS_SphChk *pSph, void *pDat) {
mVec3_c a, b, c;
cM3dGPla pla;
mVec3_c cylSphDiff = mCyl.mCenter - pSph->mCenter;
f32 SphRad = pSph->mRadius;
f32 dist = EGG::Math<f32>::sqrt(cylSphDiff.x * cylSphDiff.x + cylSphDiff.z * cylSphDiff.z);
f32 CylRad = mCyl.mRadius;
if (dist > SphRad + CylRad || dist < CylRad - SphRad) {
return false;
}
mVec3_c diff = pSph->mCenter - mCyl.mCenter;
diff.y = 0.0f;
f32 mag = VEC3Len(diff);
if (cM3d_IsZero(mag)) {
return false;
}
diff *= 1.0f / mag;
diff *= mCyl.mRadius;
mVec3_c adj;
adj.y = pSph->mCenter.y + diff.y;
adj.x = mCyl.mCenter.x + diff.x;
adj.z = mCyl.mCenter.z + diff.z;
if (!fn_803537a0(&cylSphDiff, pSph)) {
fn_80353a00(pSph, &adj);
GetTriPnt(*pSph, &a, &b, &c);
sVtx[0].x = a.x;
sVtx[0].y = a.y;
sVtx[0].z = a.z;
sVtx[1].x = b.x;
sVtx[1].y = b.y;
sVtx[1].z = b.z;
sVtx[2].x = c.x;
sVtx[2].y = c.y;
sVtx[2].z = c.z;
pla = pSph->GetPlane();
pSph->mField_0x80 = dist;
pSph->mField_0x84.set(adj.x, adj.y, adj.z);
pSph->mCallback(pSph, sVtx, 0, 1, 2, &pla, pDat);
return true;
}
return false;
}
s32 dBgWTime::GetGrpRoomIndex(cBgS_PolyInfo const &) const {
return 0x3F;
}
s32 dBgWTime::GetExitId(cBgS_PolyInfo const &) {
return 0xFF;
}
s32 dBgWTime::GetZTargetThrough(cBgS_PolyInfo const &) {
return 0;
}
int dBgWTime::GetSpecialCode(cBgS_PolyInfo const &) {
return 0;
}
int dBgWTime::GetSpecialCode(int) {
return 0;
}
int dBgWTime::GetCode0_0x30000000(cBgS_PolyInfo const &) {
return 0;
}
u32 dBgWTime::GetPolyObjThrough(int) {
return 0;
}
u32 dBgWTime::GetPolyCamThrough(int) {
return 0;
}
u32 dBgWTime::GetPolyLinkThrough(int) {
return 0;
}
u32 dBgWTime::GetPolyArrowThrough(int) {
return 0;
}
u32 dBgWTime::GetPolySlingshotThrough(int) {
return 0;
}
u32 dBgWTime::GetPolyBeetleThrough(int) {
return 0;
}
u32 dBgWTime::GetPolyClawshotThrough(int) {
return 0;
}
u32 dBgWTime::GetPolyBombThrough(int) {
return 0;
}
u32 dBgWTime::GetPolyWhipThrough(int) {
return 0;
}
u32 dBgWTime::GetShdwThrough(int) {
return 0;
}
u32 dBgWTime::GetUnderwaterRoofCode(int) {
return 1;
}
int dBgWTime::GetCode0_0x80000000(cBgS_PolyInfo const &) {
return 0;
}
int dBgWTime::GetLinkNo(cBgS_PolyInfo const &) {
return 0xFF;
}
s32 dBgWTime::GetWallCode(cBgS_PolyInfo const &) {
return 2 /* Cannot Run Up */;
}
int dBgWTime::GetPolyAtt0Material(cBgS_PolyInfo const &) {
return 0;
}
int dBgWTime::GetPolyAtt0(cBgS_PolyInfo const &) {
return 0;
}
int dBgWTime::GetPolyAtt1(cBgS_PolyInfo const &) {
return 0;
}
int dBgWTime::GetGroundCode(cBgS_PolyInfo const &) {
return 6 /* POLY_GROUND_6 */;
}
u32 dBgWTime::GetCode1_0x02000000(int) {
return 0;
}
u32 dBgWTime::GetCode1_0x04000000(int) {
return 0;
}
u32 dBgWTime::GetCode1_0x08000000(int) {
return 0;
}
u32 dBgWTime::GetLightingCode(cBgS_PolyInfo const &) {
return 0xF;
}
s32 dBgWTime::GetCamMoveBG(cBgS_PolyInfo const &) {
return 0;
}
s32 dBgWTime::GetRoomCamId(cBgS_PolyInfo const &) {
return 0;
}
s32 dBgWTime::GetRoomPathId(cBgS_PolyInfo const &) {
return 0xFF;
}
s32 dBgWTime::GetRoomPathPntNo(cBgS_PolyInfo const &) {
return 0xFF;
}
void dBgWTime::CrrPos(cBgS_PolyInfo const &, void *, bool, mVec3_c *, mAng3_c *, mAng3_c *) {}
void dBgWTime::TransPos(cBgS_PolyInfo const &, void *, bool, mVec3_c *, mAng3_c *, mAng3_c *) {}
void dBgWTime::MatrixCrrPos(cBgS_PolyInfo const &, void *, bool, mVec3_c *, mAng3_c *, mAng3_c *) {}
bool dBgWTime::GetIsDraw(int) {
return false;
}
void dBgWTime::DrawOnMap(int, bool) {}
+11
View File
@@ -0,0 +1,11 @@
#include "d/col/c/c_bg_s_chk.h"
cBgS_Chk::cBgS_Chk()
: mPolyPassChk(nullptr), mGrpPassChk(nullptr), mActorId(0), mField_0x0C(0), mField_0x0E(1), mField_0x10(1) {}
cBgS_Chk::~cBgS_Chk() {}
void cBgS_Chk::SetActorID(u32 *pId) {
u32 id = pId ? *pId : 0;
mActorId = id;
}
+18
View File
@@ -0,0 +1,18 @@
#include "d/col/c/c_bg_s_gnd_chk.h"
cBgS_GndChk::cBgS_GndChk() {
mPos = mVec3_c::Zero;
mField_0x74 = 1;
}
cBgS_GndChk::~cBgS_GndChk() {}
void cBgS_GndChk::SetPos(const mVec3_c &pPos) {
mPos.x = pPos.x;
mPos.y = pPos.y;
mPos.z = pPos.z;
}
void cBgS_GndChk::SetPos(const mVec3_c *pPos) {
mPos = *pPos;
}
+29
View File
@@ -0,0 +1,29 @@
#include "d/col/c/c_bg_s_lin_chk.h"
cBgS_LinChk::cBgS_LinChk() {
Ct();
}
cBgS_LinChk::~cBgS_LinChk() {}
void cBgS_LinChk::Ct() {
mVec3_c set = mVec3_c::Zero;
mLin.Set(set, set);
mField_0x6C = set;
mPreRoofChk = false;
mPreWallChk = false;
mPreGroundChk = false;
mFrontFlag = true;
mBackFlag = false;
mHit = false;
}
void cBgS_LinChk::Set2(const mVec3_c &start, const mVec3_c &end, u32 id) {
mLin.Set(start, end);
mField_0x6C = end;
mActorId = id;
mHit = false;
ClearPi();
}
void cBgS_LinChk::SetEnd(const mVec3_c *) {}
+35
View File
@@ -0,0 +1,35 @@
#include "d/col/c/c_bg_s_poly_info.h"
#include "d/col/bg/d_bg_s.h"
bool cBgS_PolyInfo::ChkSetInfo() const {
if (mPolyIndex == 0xFFFF || mBgIndex == BG_ID_MAX) {
return false;
}
return true;
}
void cBgS_PolyInfo::SetPolyInfo(const cBgS_PolyInfo &other) {
*this = other;
}
bool cBgS_PolyInfo::ChkSafe(const void *pBg, s32 id) const {
if (unk_0x04 == pBg && mActorPId == id) {
return true;
}
return false;
}
bool cBgS_PolyInfo::ChkBgIndex() const {
return mBgIndex != BG_ID_MAX;
}
mAng cBgS_PolyInfo::GetAngle(mAng angle) const {
cM3dGPla pla;
if (!dBgS::GetInstance()->GetTriPla(*this, &pla)) {
return mAng(0);
} else {
return pla.GetAngle(angle);
}
}
+22
View File
@@ -0,0 +1,22 @@
#include "d/col/c/c_bg_s_shdw_draw.h"
cBgS_ShdwDraw::cBgS_ShdwDraw() {
mpPla = nullptr;
}
cBgS_ShdwDraw::~cBgS_ShdwDraw() {}
void cBgS_ShdwDraw::Set(const mVec3_c &start, const mVec3_c &end) {
mBnd.Set(start, end);
}
void cBgS_ShdwDraw::SetCallback(cBgS_ShdwDraw_Callback pCallback) {
mpCallback = pCallback;
}
void cBgS_ShdwDraw::SetP(cM3dGPla *pPla) {
mpPla = pPla;
}
void cBgS_ShdwDraw::Calc(cM3dGTri *, mVec3_c *, mVec3_c *, mVec3_c *) {
// TODO
}
+21
View File
@@ -0,0 +1,21 @@
#include "d/col/c/c_bg_w.h"
cBgW_BgId::cBgW_BgId() {
Ct();
}
cBgW_BgId::~cBgW_BgId() {}
void cBgW_BgId::Regist(int id) {
m_id = id;
}
void cBgW_BgId::Release() {
Ct();
}
bool cBgW_BgId::ChkUsed() const {
// What??
u16 id = GetId();
return id <= BG_ID_MAX - 1;
}
View File
+3
View File
@@ -0,0 +1,3 @@
#include "d/col/c/c_m2d.h"
void cM2d_CrossCirLin(cM2dGCir &, float, float, float, float, float *, float *) {}
+242
View File
@@ -0,0 +1,242 @@
#include "d/col/c/c_m3d.h"
#include "d/col/c/c_m3d_g_aab.h"
#include "d/col/c/c_m3d_g_cir.h"
#include "d/col/c/c_m3d_g_cps.h"
#include "d/col/c/c_m3d_g_cyl.h"
#include "d/col/c/c_m3d_g_lin.h"
#include "d/col/c/c_m3d_g_pla.h"
#include "d/col/c/c_m3d_g_sph.h"
#include "d/col/c/c_m3d_g_tri.h"
#include "d/col/c/c_m3d_g_unk.h"
#include "egg/math/eggMath.h"
#include "m/m_vec.h"
#include "math.h"
#include "nw4r/math/math_types.h"
#include "rvl/MTX.h"
using namespace nw4r::math;
using namespace EGG;
const f32 G_CM3D_F_ABS_MIN = 32 * FLT_EPSILON;
inline void cM3d_Cross(const VEC3 *pVecA, const VEC3 *pVecB, const VEC3 *pVecC, VEC3 *pVecOut) {
VEC3 tmp1;
VEC3 tmp2;
VEC3Sub(&tmp1, pVecB, pVecA);
VEC3Sub(&tmp2, pVecC, pVecA);
VEC3Cross(pVecOut, &tmp1, &tmp2);
}
bool cM3d_Len2dSqPntAndSegLine(f32, f32, f32, f32, f32, f32, f32 *, f32 *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Len3dSqPntAndSegLine(const cM3dGLin *, const VEC3 *, VEC3 *, f32 *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
f32 cM3d_SignedLenPlaAndPos(const cM3dGPla *, const VEC3 *) {
// TODO - returns 0.0f to satisfy warning
return 0.0f;
}
void cM3d_CalcPla(const VEC3 *pVecA, const VEC3 *pVecB, const VEC3 *pVecC, VEC3 *pVecOut, f32 *pD) {
cM3d_Cross(pVecA, pVecB, pVecC, pVecOut);
f32 mag = VEC3Len(pVecOut);
if (fabsf(mag) > 0.05f) {
VEC3Scale(pVecOut, pVecOut, Math<f32>::inv(mag));
f32 dot = VEC3Dot(pVecOut, pVecA);
*pD = -dot;
} else {
pVecOut->y = 0.0f;
*pD = 0.0f;
pVecOut->z = 0.0f;
pVecOut->x = 0.0f;
}
}
int cM3d_Check_LinLin(const cM3dGLin *, const cM3dGLin *, f32 *, f32 *) {
// TODO - returns false to satisfy warning
return 0;
}
bool cM3d_Cross_LinPla(const cM3dGLin *, const cM3dGPla *, VEC3 *, bool, bool) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_MinMaxBoxLine(const VEC3 *, const VEC3 *, const VEC3 *, const VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_InclusionCheckPosIn3PosBox3d(const VEC3 *, const VEC3 *, const VEC3 *, const VEC3 *, f32) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossX_Tri(const cM3dGTri *, const VEC3 *, f32) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossX_Tri(const cM3dGTri *, const VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossY_Tri(const cM3dGTri *, const VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossY_Tri_Front(const VEC3 &, const VEC3 &, const VEC3 &, const VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossY_Tri(const cM3dGTri *, const VEC3 *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossY_Tri(const cM3dGTri *, const VEC3 *, f32) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossY_Tri(const cM3dGTri *, const VEC3 *, const cM3d_Range *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossZ_Tri(const cM3dGTri *, const VEC3 *, f32) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossZ_Tri(const cM3dGTri *, const VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_CrossZ_Tri(const cM3dGTri *, const VEC3 *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_LinTri(const cM3dGLin *, const cM3dGTri *, VEC3 *, bool, bool) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_LinTri(
const cM3dGLin *, const VEC3 *, const VEC3 *, const VEC3 *, const cM3dGPla *, VEC3 *, bool, bool
) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_LinTri_Easy(const cM3dGTri *pTri, const VEC3 *pPos) {
if ((cM3d_IsZero(pTri->mNormal.x) || cM3d_CrossX_Tri(pTri, pPos)) &&
(cM3d_IsZero(pTri->mNormal.y) || cM3d_CrossY_Tri(pTri, pPos)) &&
(cM3d_IsZero(pTri->mNormal.z) || cM3d_CrossZ_Tri(pTri, pPos))) {
return true;
}
return false;
}
bool cM3d_Cross_SphPnt(const cM3dGSph *pSph, const VEC3 *pPos) {
f32 r2 = pSph->GetR();
return VEC3DistSq(pSph->GetC(), pPos) < r2 * r2;
}
bool cM3d_Cross_LinSph(const cM3dGLin *, const cM3dGSph *, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_LinSph_CrossPos(const cM3dGSph &, const cM3dGLin &, VEC3 *, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_CylSph(const cM3dGCyl *, const cM3dGSph *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_CylSph(const cM3dGCyl *, const cM3dGSph *, VEC3 *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_SphSph(const cM3dGSph *, const cM3dGSph *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_SphSph(const cM3dGSph *, const cM3dGSph *, f32 *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_SphSph(const cM3dGSph *, const cM3dGSph *, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
void cM3d_CalcSphVsTriCrossPoint(const cM3dGSph *pSph, const cM3dGTri *pTri, VEC3 *pPnt) {
VEC3 scale, add;
PSVECAdd(pTri->mA, pTri->mB, add);
PSVECScale(add, scale, 0.5f);
f32 mag = VEC3DistSq(&scale, &pSph->GetC());
if (cM3d_IsZero(mag)) {
*pPnt = pSph->GetC();
return;
}
f32 a = pSph->GetR() / mag;
cM3d_InDivPos2(&pSph->GetC(), &scale, a, pPnt);
}
bool cM3d_Cross_SphTri(const cM3dGSph *, const cM3dGTri *, VEC3 *, f32 *, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_CylCyl(const cM3dGCyl *, const cM3dGCyl *, f32 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_CylCyl(const cM3dGCyl *, const cM3dGCyl *, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_CylTri(const cM3dGCyl *, const cM3dGTri *, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
int cM3d_Cross_CylLin(const cM3dGCyl *, const cM3dGLin *, VEC3 *, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
int cM3d_Cross_CylPntPnt(const cM3dGCyl *, const VEC3 *, const VEC3 *, VEC3 *, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_CylPnt(const cM3dGCyl *, const VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_CpsSph_CrossPos(const cM3dGCps &, const cM3dGSph &, const VEC3 &, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_CpsSph(const cM3dGCps &, const cM3dGSph &, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_TriTri(const cM3dGTri &, const cM3dGTri &, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_Cross_CpsTri(const cM3dGCps &, cM3dGTri, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
void cM3d_CalcVecZAngle(const VEC3 &, mAng3_c *) {}
void cM3d_PlaneCrossLineProcWork(f32, f32, f32, f32, f32, f32, f32, f32 *, f32 *) {}
int cM3d_2PlaneCrossLine(const cM3dGPla &, const cM3dGPla &, cM3dGLin *) {
// TODO - returns false to satisfy warning
return false;
}
bool cM3d_3PlaneCrossPos(const cM3dGPla &, const cM3dGPla &, const cM3dGPla &, VEC3 *) {
// TODO - returns false to satisfy warning
return false;
}
f32 cM3d_lineVsPosSuisenCross(const cM3dGLin *, const VEC3 *, VEC3 *) {
// TODO - returns 0.0f to satisfy warning
return 0.0f;
}
f32 cM3d_lineVsPosSuisenCross(const VEC3 &, const VEC3 &, const VEC3 &, VEC3 *) {
// TODO - returns 0.0f to satisfy warning
return 0.0f;
}
+122
View File
@@ -0,0 +1,122 @@
#include "d/col/c/c_m3d_g_aab.h"
#include "rvl/MTX.h"
void cM3dGAab::SetMin(const mVec3_c &min) {
if (mMin.x > min.x) {
mMin.x = min.x;
}
if (mMin.y > min.y) {
mMin.y = min.y;
}
if (mMin.z > min.z) {
mMin.z = min.z;
}
}
void cM3dGAab::SetMax(const mVec3_c &max) {
if (mMax.x < max.x) {
mMax.x = max.x;
}
if (mMax.y < max.y) {
mMax.y = max.y;
}
if (mMax.z < max.z) {
mMax.z = max.z;
}
}
void cM3dGAab::CalcCenter(mVec3_c &center) const {
PSVECAdd(mMin, mMax, center);
PSVECScale(center, center, 0.5f);
}
void cM3dGAab::PlusR(f32 r) {
mMin -= r;
mMax += r;
}
void cM3dGAab::Clamp(const mVec3_c &in, mVec3_c &out) const {
f32 x = in.x;
if (x < mMin.x) {
x = mMin.x;
}
if (x > mMax.x) {
x = mMax.x;
}
out.x = x;
f32 y = in.y;
if (y < mMin.y) {
y = mMin.y;
}
if (y > mMax.y) {
y = mMax.y;
}
out.y = y;
f32 z = in.z;
if (z < mMin.z) {
z = mMin.z;
}
if (z > mMax.z) {
z = mMax.z;
}
out.z = z;
}
void cM3dGAab::Set(const cM3dGSph &sph) {
mVec3_c min, max;
min = max = sph.GetC();
f32 r = sph.GetR();
f32 ratio = sph.mRatio;
if (ratio < 1.0f) {
ratio = 1.0f;
}
f32 h = r * ratio;
min.x -= r;
min.y -= h;
min.z -= r;
max.x += r;
max.y += h;
max.z += r;
Set(min, max);
}
bool cM3dGAab::Cross(const mVec3_c &pos) const {
if ((mMin.x < pos.x && pos.x < mMax.x) && (mMin.y < pos.y && pos.y < mMax.y) &&
(mMin.z < pos.z && pos.z < mMax.z)) {
return true;
}
return false;
}
void cM3dGAab::SetBounds(const mVec3_c &pntA, const mVec3_c &pntB) {
if (pntA.x < pntB.x) {
mMin.x = pntA.x;
mMax.x = pntB.x;
} else {
mMin.x = pntB.x;
mMax.x = pntA.x;
}
if (pntA.y < pntB.y) {
mMin.y = pntA.y;
mMax.y = pntB.y;
} else {
mMin.y = pntB.y;
mMax.y = pntA.y;
}
if (pntA.z < pntB.z) {
mMin.z = pntA.z;
mMax.z = pntB.z;
} else {
mMin.z = pntB.z;
mMax.z = pntA.z;
}
PlusR(1.0f);
}
+7
View File
@@ -0,0 +1,7 @@
#include "d/col/c/c_m3d_g_cir.h"
/**
* File Not Used
*
* cM3dGCir vtable could be from here or in c_m3d
*/
+47
View File
@@ -0,0 +1,47 @@
#include "d/col/c/c_m3d_g_cps.h"
#include "d/col/c/c_m3d.h"
#include "nw4r/math.h"
cM3dGCps::cM3dGCps() {
mField_0x1C = 0.0f;
mField_0x20 = 0;
mFlags = 0;
}
void cM3dGCps::SetR(f32 r) {
if (r < 0.0f) {
r = 0.0f;
}
mRadius = r;
mField_0x1C = (double)r; // huh
}
void cM3dGCps::Set_0x1C(f32 f) {
mField_0x1C = f;
}
void cM3dGCps::Set(const mVec3_c &start, const mVec3_c &end, f32 r) {
cM3dGLin::Set(start, end);
SetR(r);
}
bool cM3dGCps::fn_80337f30(cM3dGUnk *unk, mVec3_c *vec) {
return fn_80336d90(this, unk, vec);
}
bool cM3dGCps::fn_80337f40(const mVec3_c &v) const {
f32 r2 = mRadius * mRadius;
if (!(mFlags & 1) && PSVECSquareDistance(mStart, v) <= r2) {
return true;
}
if (!(mFlags & 2) && PSVECSquareDistance(mEnd, v) <= r2) {
return true;
}
f32 tmp;
mVec3_c tmpv;
if (cM3d_Len3dSqPntAndSegLine(this, v, tmpv, &tmp, nullptr) && tmp <= r2) {
return true;
}
return false;
}
+86
View File
@@ -0,0 +1,86 @@
#include "d/col/c/c_m3d_g_cyl.h"
#include "d/col/c/c_m3d.h"
#include "m/m_vec.h"
void cM3dGCyl::SetC(const mVec3_c &c, f32 radius, f32 height) {
SetC(c);
SetR(radius);
SetH(height);
}
void cM3dGCyl::SetC(const mVec3_c &c) {
mCenter = c;
}
void cM3dGCyl::SetH(f32 h) {
if (h < 0.0f) {
h = 0.0f;
}
mHeight = h;
}
void cM3dGCyl::SetR(f32 r) {
if (r < 0.0f) {
r = 0.0f;
}
mRadius = r;
}
bool cM3dGCyl::fn_803380e0(cM3dGUnk *unk, mVec3_c *vec) {
return fn_80336110(this, unk, vec);
}
bool cM3dGCyl::fn_803380f0(cM3dGUnk *unk, f32 *vec) {
return fn_803364e0(this, unk, vec);
}
bool cM3dGCyl::Cross(const mVec3_c &pnt) const {
if ((mCenter.y > pnt.y) || (mCenter.y + mHeight < pnt.y)) {
return false;
}
f32 x_dist = mCenter.x - pnt.x;
f32 z_dist = mCenter.z - pnt.z;
return x_dist * x_dist + z_dist * z_dist > mRadius * mRadius ? false : true;
}
void cM3dGCyl::Clamp(const mVec3_c &in, mVec3_c &out) const {
f32 floor = mCenter.y;
mVec3_c diff = in - mCenter;
f32 ceil = floor + mHeight;
f32 dist_sq = diff.x * diff.x + diff.z * diff.z;
f32 dist = EGG::Math<f32>::sqrt(dist_sq);
if (ceil < in.y) {
if (dist < mRadius) {
out.x = in.x;
out.y = ceil;
out.z = in.z;
} else {
f32 scale = mRadius / dist;
out.x = mCenter.x + scale * (in.x - mCenter.x);
out.y = ceil;
out.z = mCenter.z + scale * (in.z - mCenter.z);
}
} else if (floor > in.y) {
if (dist < mRadius) {
out.x = in.x;
out.y = floor;
out.z = in.z;
} else {
f32 scale = mRadius / dist;
out.y = floor;
out.x = mCenter.x + scale * (in.x - mCenter.x);
out.z = mCenter.z + scale * (in.z - mCenter.z);
}
} else {
if (dist < mRadius) {
out = in;
} else {
f32 scale = mRadius / dist;
out.y = in.y;
out.x = mCenter.x + scale * (in.x - mCenter.x);
out.z = mCenter.z + scale * (in.z - mCenter.z);
}
}
}
+22
View File
@@ -0,0 +1,22 @@
#include "d/col/c/c_m3d_g_lin.h"
void cM3dGLin::SetStartEnd(const VEC3 &start, const VEC3 &end) {
mStart = start;
mEnd = end;
}
void cM3dGLin::SetStartEnd(const mVec3_c *start, const mVec3_c *end) {
SetStartEnd(*start, *end);
}
void cM3dGLin::CalcPos(mVec3_c *out, f32 scale) const {
mVec3_c tmp;
PSVECSubtract(mEnd, mStart, tmp);
PSVECScale(tmp, tmp, scale);
PSVECAdd(tmp, mStart, *out);
}
void cM3dGLin::SetStart(const mVec3_c &start) {
// This just feels weird
mStart = start;
}
+39
View File
@@ -0,0 +1,39 @@
#include "d/col/c/c_m3d_g_pla.h"
#include "d/col/c/c_m3d.h"
bool cM3dGPla::CrossInfLin(const mVec3_c &start, const mVec3_c &end, mVec3_c &out) const {
f32 tmp1 = getPlaneFunc(start);
f32 tmp2 = getPlaneFunc(end);
if (cM3d_IsZero(tmp1 - tmp2)) {
out = end;
return false;
}
f32 pF = tmp1 / (tmp1 - tmp2);
cM3d_InDivPos2(&start, &end, pF, &out);
return true;
}
bool cM3dGPla::getCrossYLessD(const mVec3_c &point, f32 *out) const {
if (cM3d_IsZero(mNormal.y)) {
return false;
} else {
*out = (-mNormal.x * point.x - mNormal.z * point.z) / mNormal.y;
return true;
}
}
mAng cM3dGPla::GetAngle(mAng ang) const {
mAng angleY = GetAngleY();
// Regswap
angleY = angleY - ang;
f32 dist = GetXZDist() * angleY.cos();
return cM::atan2s(dist, mNormal.y);
}
mAng cM3dGPla::GetNegativeAngle(mAng ang) const {
return -GetAngle(ang);
}
+63
View File
@@ -0,0 +1,63 @@
#include "d/col/c/c_m3d_g_sph.h"
#include "m/m_vec.h"
cM3dGSph::cM3dGSph() {
mRatio = 1.0f;
}
void cM3dGSph::SetC(const mVec3_c *c) {
mCenter = *c;
}
void cM3dGSph::Set(const mVec3_c *c, f32 r) {
SetC(c);
SetR(r);
}
void cM3dGSph::SetR(f32 r) {
if (r < 0.0f) {
r = 0.0f;
}
mRadius = r;
}
void cM3dGSph::SetC(f32 x, f32 y, f32 z) {
mVec3_c c(x, y, z);
SetC(&c);
}
bool cM3dGSph::fn_80338750(cM3dGUnk *pUnk, mVec3_c *pOut) {
return fn_80337690(pUnk, this, pOut);
}
bool cM3dGSph::fn_80338760(cM3dGUnk *pUnk, f32 *pOut) {
return fn_80337780(pUnk, this, pOut);
}
f32 cM3dGSph::GetYDist(f32 r) const {
f32 b = mRadius * mRadius - (r - mCenter.y) * (r - mCenter.y);
if (b < 0.0f) {
return 0.0f;
}
return nw4r::math::FSqrt(b);
}
bool cM3dGSph::Cross(const cM3dGTri *pTri, f32 *p2, mVec3_c *p3) {
return cM3d_Cross_SphTri(this, pTri, nullptr, p2, p3);
}
void cM3dGSph::Clamp(const mVec3_c &in, mVec3_c &out) const {
f32 dist = EGG::Math<f32>::sqrt(VEC3DistSq(mCenter, in));
if (dist < mRadius) {
out = in;
} else {
f32 a = mRadius / dist;
out = (in - mCenter) * a + mCenter;
}
}
void cM3dGSph::SetRatio(f32 ratio) {
mRatio = ratio;
}
+10
View File
@@ -0,0 +1,10 @@
#include "d/col/c/c_m3d_g_tri.h"
using nw4r::math::VEC3;
void cM3dGTri::SetPos(const VecType *vA, const VecType *vB, const VecType *vC) {
mA = *vA;
mB = *vB;
mC = *vC;
cM3d_CalcPla(&mA, &mB, &mC, &mNormal, &mD);
}
+133
View File
@@ -0,0 +1,133 @@
#include "d/col/c/c_m3d_g_unk.h"
#include "d/col/c/c_m3d.h"
#include "d/col/c/c_m3d_g_aab.h"
cM3dGUnk::cM3dGUnk() {
mMin.set(0.0f, 0.0f, 0.0f);
mMax.set(0.0f, 0.0f, 0.0f);
mField_0x78.set(0.0f, 0.0f, 0.0f);
mField_0x84.set(0.0f, 0.0f, 0.0f);
mField_0x90.set(0.0f, 0.0f, 0.0f);
mField_0x9C.set(0.0f, 0.0f, 0.0f);
mField_0xA8.set(0.0f, 0.0f, 0.0f);
mField_0xB4 = 0;
mVirtCenter.set(0.0f, 0.0f, 0.0f);
mField_0xC4 = 0.0f;
PSMTXIdentity(mMtx);
PSMTXIdentity(mInvMtx);
}
void cM3dGUnk::Set(const mVec3_c &vA, const mVec3_c &vB) {
mMin = vA;
mMax = vB;
mField_0x84 = (mMin + mMax) * 0.5f;
mField_0x90 = mMin - mField_0x84;
mField_0x9C = mMax - mField_0x84;
mField_0xA8 = (mMax - mMin) * 0.5f;
Update();
}
void cM3dGUnk::Update() {
mVec3_c a, b;
PSMTXMultVec(mMtx, mMin, a);
PSMTXMultVec(mMtx, mMax, b);
mField_0x78.x = (a.x + b.x) * 0.5f;
mField_0x78.y = (a.y + b.y) * 0.5f;
mField_0x78.z = (a.z + b.z) * 0.5f;
if (!PSMTXInverse(mMtx, mInvMtx)) {
PSMTXIdentity(mInvMtx);
}
}
void cM3dGUnk::GetStartEnd(mVec3_c &start, mVec3_c &end) {
start = mMin;
end = mMax;
}
void cM3dGUnk::fn_80338c30(cM3dGCps *pCps, mVec3_c *pVec) {
fn_80336d90(pCps, this, pVec);
}
bool cM3dGUnk::fn_80338c40(cM3dGUnk *pUnk, mVec3_c *pVec) {
nw4r::math::VEC3 tmp;
if (fn_803354e0(this, pUnk, &tmp)) {
*pVec = tmp;
return true;
}
return false;
}
bool cM3dGUnk::fn_80338ca0() {
return false;
}
bool cM3dGUnk::fn_80338cb0(cM3dGCyl *pCyl, mVec3_c *pVec) {
return fn_80336110(pCyl, this, pVec);
}
bool cM3dGUnk::fn_80338cc0(cM3dGCyl *pCyl, f32 *pF) {
return fn_803364e0(pCyl, this, pF);
}
bool cM3dGUnk::fn_80338cd0(cM3dGSph *pSph, mVec3_c *pVec) {
return fn_80337690(this, pSph, pVec);
}
bool cM3dGUnk::fn_80338ce0(cM3dGSph *pSph, f32 *pF) {
return fn_80337780(this, pSph, pF);
}
void cM3dGUnk::Set(const mMtx_c &mtx) {
mMtx.set(mtx);
Update();
}
void cM3dGUnk::Set(const mVec3_c &vec, const mAng &ang) {
mMtx_c mtx;
PSMTXIdentity(mtx);
mtx.YrotS(ang);
mtx.SetTranslation(vec);
Set(mtx);
}
bool cM3dGUnk::Cross(const mVec3_c &vec) {
mVec3_c tmp;
PSMTXMultVec(mInvMtx, vec, tmp);
if ((tmp.x < mMin.x)) {
return false;
}
if (tmp.x > mMax.x) {
return false;
}
if (tmp.y < mMin.y) {
return false;
}
if (tmp.y > mMax.y) {
return false;
}
if (tmp.z < mMin.z) {
return false;
}
if (tmp.z > mMax.z) {
return false;
}
return true;
}
void cM3dGUnk::Clamp(const mVec3_c &in, mVec3_c &out) {
mVec3_c tmp1, tmp2;
PSMTXMultVec(mInvMtx, in, tmp1);
cM3dGAab aab;
aab.Set(mMin, mMax);
aab.Clamp(tmp1, tmp2);
PSMTXMultVec(mMtx, tmp2, out);
}
void cM3dGUnk::fn_80338f30(f32 f0, f32 f1) {
mMtx.xw += f0;
mMtx.zw += f1;
Update();
}
+11
View File
@@ -0,0 +1,11 @@
#include "d/col/c/c_partition.h"
cPartition::cPartition() {
mX = 0;
mY = 0;
mZ = 0;
}
cPartition::~cPartition() {}
// TODO
@@ -1,7 +1,7 @@
#include <d/a/d_a_base.h>
#include <d/col/cc/d_cc_d.h>
#include <f/f_base_id.h>
#include <m/m_vec.h>
#include <toBeSorted/cc/d_cc_d.h>
inline bool cM3d_IsZero(f32 f);
@@ -26,7 +26,7 @@ void d_cc_d_float_order() {
}
// Very certain
void dCcD_DivideArea::SetArea(Aabb const &aab) {
void dCcD_DivideArea::SetArea(cM3dGAab const &aab) {
Set(aab.mMin, aab.mMax);
mScaledXDiff = 1.0f / 32.0f * (mMax.x - mMin.x);
@@ -53,38 +53,10 @@ inline bool cM3d_IsZero(f32 f) {
}
static u32 const l_base[32] = {
0x00000001,
0x00000003,
0x00000007,
0x0000000F,
0x0000001F,
0x0000003F,
0x0000007F,
0x000000FF,
0x000001FF,
0x000003FF,
0x000007FF,
0x00000FFF,
0x00001FFF,
0x00003FFF,
0x00007FFF,
0x0000FFFF,
0x0001FFFF,
0x0003FFFF,
0x0007FFFF,
0x000FFFFF,
0x001FFFFF,
0x003FFFFF,
0x007FFFFF,
0x00FFFFFF,
0x01FFFFFF,
0x03FFFFFF,
0x07FFFFFF,
0x0FFFFFFF,
0x1FFFFFFF,
0x3FFFFFFF,
0x7FFFFFFF,
0xFFFFFFFF,
0x00000001, 0x00000003, 0x00000007, 0x0000000F, 0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF,
0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF, 0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF,
0x0001FFFF, 0x0003FFFF, 0x0007FFFF, 0x000FFFFF, 0x001FFFFF, 0x003FFFFF, 0x007FFFFF, 0x00FFFFFF,
0x01FFFFFF, 0x03FFFFFF, 0x07FFFFFF, 0x0FFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF,
};
// TODO
@@ -271,11 +243,11 @@ dCcD_ShapeAttr5::dCcD_ShapeAttr5() {}
dCcD_ShapeAttr5::~dCcD_ShapeAttr5() {}
void dCcD_ShapeAttr5::init(const dCcD_SrcAabbAttr &src) {
setMinMax(mVec3_c(src.minX, src.minY, src.minZ), mVec3_c(src.maxX, src.maxY, src.maxZ));
Set(mVec3_c(src.minX, src.minY, src.minZ), mVec3_c(src.maxX, src.maxY, src.maxZ));
}
mVec3_c *dCcD_ShapeAttr5::getVirtualCenter() {
return &mVirtualCenter;
return &mVirtCenter;
}
dCcD_ShapeAttr1::dCcD_ShapeAttr1() {}
@@ -290,13 +262,13 @@ dCcD_ShapeAttr3::dCcD_ShapeAttr3() {}
dCcD_ShapeAttr3::~dCcD_ShapeAttr3() {}
void dCcD_ShapeAttr3::init(const dCcD_SrcCylAttr &src) {
setR(src.mRadius);
setH(src.mHeight);
SetR(src.mRadius);
SetH(src.mHeight);
mVec3_c v;
v.z = 0.0f;
v.y = 0.0f;
v.x = 0.0f;
setC(v);
SetC(v);
}
mVec3_c *dCcD_ShapeAttr3::getVirtualCenter() {
@@ -307,12 +279,12 @@ dCcD_ShapeAttr4::dCcD_ShapeAttr4() {}
dCcD_ShapeAttr4::~dCcD_ShapeAttr4() {}
void dCcD_ShapeAttr4::init(const dCcD_SrcSphAttr &src) {
setR(src.mRadius);
SetR(src.mRadius);
mVec3_c v;
v.z = 0.0f;
v.y = 0.0f;
v.x = 0.0f;
setC(v);
SetC(v);
}
mVec3_c *dCcD_ShapeAttr4::getVirtualCenter() {
@@ -1,6 +1,6 @@
#include <d/col/cc/d_cc_d.h>
#include <d/col/cc/d_cc_shape_colliders.h>
#include <m/m_vec.h>
#include <toBeSorted/cc/d_cc_d.h>
#include <toBeSorted/cc/d_cc_shape_colliders.h>
dCcD_Unk1::dCcD_Unk1() {}
dCcD_Unk1::~dCcD_Unk1() {}
@@ -18,7 +18,7 @@ void *dCcD_Unk1::dCcD_GObjInf_0x0C() {
}
void dCcD_Unk1::unknownCalc() {
PSVECSubtract(*&field_0x0C, *&field_0x00, *getAtVec());
PSVECSubtract(mCps.mEnd, mCps.mStart, *getAtVec());
}
dCcD_Empty::dCcD_Empty() {}
@@ -52,12 +52,12 @@ void *dCcD_Cyl::dCcD_GObjInf_0x0C() {
void dCcD_Cyl::setCenter(const mVec3_c &c) {
setAtVec(mVec3_c::Zero);
setC(c);
SetC(c);
}
void dCcD_Cyl::moveCenter(const mVec3_c &c) {
setAtVec(c - GetC());
setC(c);
SetC(c);
}
dCcD_Sph::dCcD_Sph() {}
@@ -70,17 +70,17 @@ void dCcD_Sph::init(const dCcD_SrcSph &src) {
void dCcD_Sph::setCenter(const mVec3_c &c) {
setAtVec(mVec3_c::Zero);
setC(c);
SetC(&c);
}
void dCcD_Sph::moveCenter(const mVec3_c &c) {
setAtVec(c - GetC());
setC(c);
SetC(&c);
}
void dCcD_Sph::setCenterAndAtVec(const mVec3_c &a, const mVec3_c &b) {
setAtVec(b);
setC(a);
SetC(&a);
}
void *dCcD_Sph::dCcD_GObjInf_0x0C() {
+3 -6
View File
@@ -1,19 +1,16 @@
#include <d/lyt/d_structd.h>
namespace d2d
{
namespace d2d {
dLytStructDList::dLytStructDList() {
field_0x18 = true;
sInstance = this;
}
dLytStructDList *dLytStructDList::create(EGG::Heap *heap) {
return new(heap) dLytStructDList();
return new (heap) dLytStructDList();
}
void dLytStructDList::appendToList1(dLytStructD *other) {
mList1.insert(other);
}
+10 -12
View File
@@ -1,23 +1,24 @@
#include <d/col/bg/d_bg_s.h>
#include <d/col/bg/d_bg_w_kcol.h>
#include <d/d_rawarchive.h>
#include <egg/gfx/eggLight.h>
#include <m/m3d/m3d.h>
#include <toBeSorted/arc_managers/oarc_manager.h>
#include <toBeSorted/arc_managers/current_stage_arc_manager.h>
#include <nw4r/g3d/g3d_resfile.h>
#include <nw4r/g3d/g3d_resmdl.h>
#include <nw4r/g3d/g3d_resmat.h>
#include <nw4r/g3d/g3d_resmdl.h>
#include <toBeSorted/arc_managers/current_stage_arc_manager.h>
#include <toBeSorted/arc_managers/oarc_manager.h>
ArcCallbackHandler ArcCallbackHandler::sInstance;
#define NAME_DZB 'dzb '
#define NAME_G3D 'g3d '
#define NAME_KCL 'kcl '
#define NAME_DZB 'dzb '
#define NAME_G3D 'g3d '
#define NAME_KCL 'kcl '
#define NAME_OARC 'oarc'
#define NAME_RARC 'rarc'
extern "C" void FUN_804a7260(nw4r::g3d::ResMdl, const char *prefix);
void BindSystemModelsAndLighting(nw4r::g3d::ResFile file) {
nw4r::g3d::ResFile sysFile = OarcManager::sInstance->getMdlFromArc2("System");
if (sysFile.mFile.IsValid()) {
@@ -48,9 +49,6 @@ void BindSystemModelsAndLighting(nw4r::g3d::ResFile file) {
}
}
extern "C" void fn_8033A140(void *data);
extern "C" void dBgWKCol__initKCollision(void *dat);
void ArcCallbackHandlerBase::CreateArcEntry(void *data, const char *path) {
if (mPrefix == NAME_G3D) {
nw4r::g3d::ResFile file = data;
@@ -58,9 +56,9 @@ void ArcCallbackHandlerBase::CreateArcEntry(void *data, const char *path) {
file.Bind();
BindSystemModelsAndLighting(file);
} else if (mPrefix == NAME_KCL) {
dBgWKCol__initKCollision(data);
dBgWKCol::initKCollision(data);
} else if (mPrefix == NAME_DZB) {
fn_8033A140(data);
cBgS::ConvDzb(data);
} else if (mPrefix == NAME_OARC) {
SizedString<64> oarcPath = path;
char buf[64];
-33
View File
@@ -1,33 +0,0 @@
#include <math.h>
#include <nw4r/math/math_types.h>
#include <rvl/MTX.h>
using namespace nw4r::math;
inline VEC3 cM3d_Cross(const VEC3 *pVecA, const VEC3 *pVecB, const VEC3 *pVecC, VEC3 *pVecOut) {
VEC3 tmp1;
VEC3 tmp2;
VEC3Sub(&tmp1, pVecB, pVecA);
VEC3Sub(&tmp2, pVecC, pVecA);
VEC3Cross(pVecOut, &tmp1, &tmp2);
}
inline f32 cM3d_Dot(const VEC3 *pVecA, const VEC3 *pVecB) {
return VEC3Dot(pVecA, pVecB);
}
void cM3d_CalcPla(const VEC3 *pVecA, const VEC3 *pVecB, const VEC3 *pVecC, VEC3 *pVecOut, f32 *pD) {
cM3d_Cross(pVecA, pVecB, pVecC, pVecOut);
f32 mag = VEC3Len(pVecOut);
if (fabsf(mag) > 0.05f) {
VEC3Scale(pVecOut, pVecOut, 1.0f / mag);
*pD = -cM3d_Dot(pVecOut, pVecA);
} else {
pVecOut->y = 0.0f;
*pD = 0.0f;
pVecOut->z = 0.0f;
pVecOut->x = 0.0f;
}
}
-26
View File
@@ -1,26 +0,0 @@
#include <m/m_vec.h>
#include <toBeSorted/cc/d_cc_m3d_g_cyl.h>
void cM3dGCyl::setC(const mVec3_c &c, f32 radius, f32 height) {
setC(c);
setR(radius);
setH(height);
}
void cM3dGCyl::setC(const mVec3_c &c) {
mCenter = c;
}
void cM3dGCyl::setH(f32 h) {
if (h < 0.0f) {
h = 0.0f;
}
mHeight = h;
}
void cM3dGCyl::setR(f32 r) {
if (r < 0.0f) {
r = 0.0f;
}
mRadius = r;
}
-26
View File
@@ -1,26 +0,0 @@
#include <m/m_vec.h>
#include <toBeSorted/cc/d_cc_m3d_g_sph.h>
cM3dGSph::cM3dGSph() {
field_0x10 = 1.0f;
}
void cM3dGSph::setC(const mVec3_c &c) {
mCenter = c;
}
void cM3dGSph::set(const mVec3_c &c, f32 r) {
setC(c);
setR(r);
}
void cM3dGSph::setR(f32 r) {
if (r < 0.0f) {
r = 0.0f;
}
mRadius = r;
}
void cM3dGSph::setC(f32 x, f32 y, f32 z) {
setC(mVec3_c(x, y, z));
}
+15 -21
View File
@@ -5,19 +5,12 @@
#include <toBeSorted/item_story_flag_manager.h>
#include <toBeSorted/tlist.h>
typedef TList<DowsingTarget, 0> DowsingList;
typedef TList<DowsingTarget, offsetof(DowsingTarget, mLink)> DowsingList;
DowsingList DOWSING_LISTS[8];
static const int DOWSING_TARGET_STORY_FLAGS[8] = {
100,
105,
100,
104,
108,
110,
109,
102,
100, 105, 100, 104, 108, 110, 109, 102,
};
DowsingTarget::~DowsingTarget() {
@@ -56,7 +49,7 @@ void DowsingTarget::getPosition(mVec3_c &position) {
mMtx_c mtx2;
PSMTXTrans(mtx.m, mpActor->position.x, mpActor->position.y, mpActor->position.z);
mtx.YrotM(mpActor->rotation.y);
PSMTXScale(mtx2.m, mpActor->scale.x, mpActor->scale.y, mpActor->scale.z);
PSMTXScale(mtx2.m, mpActor->mScale.x, mpActor->mScale.y, mpActor->mScale.z);
PSMTXConcat(mtx.m, mtx2.m, mtx.m);
PSMTXMultVec(mtx.m, mOffset, position);
}
@@ -80,9 +73,9 @@ bool DowsingTarget::hasDesertNodeDowsing() {
bool DowsingTarget::hasAnyTrialDowsing() {
// TODO more complicated code
return ItemFlagManager::sInstance->getFlag(187) && !StoryFlagManager::sInstance->getCounterOrFlag(93) ||
ItemFlagManager::sInstance->getFlag(188) && !StoryFlagManager::sInstance->getCounterOrFlag(97) ||
ItemFlagManager::sInstance->getFlag(189) && !StoryFlagManager::sInstance->getCounterOrFlag(98) ||
ItemFlagManager::sInstance->getFlag(193) && !StoryFlagManager::sInstance->getCounterOrFlag(99);
ItemFlagManager::sInstance->getFlag(188) && !StoryFlagManager::sInstance->getCounterOrFlag(97) ||
ItemFlagManager::sInstance->getFlag(189) && !StoryFlagManager::sInstance->getCounterOrFlag(98) ||
ItemFlagManager::sInstance->getFlag(193) && !StoryFlagManager::sInstance->getCounterOrFlag(99);
}
bool DowsingTarget::hasSacredWaterDowsing() {
@@ -132,10 +125,10 @@ bool DowsingTarget::hasDowsingInSlot(int slot) {
if (slot == 0) {
return hasZeldaDowsing() || hasAnyTrialDowsing() || hasSacredWaterDowsing() || hasSandshipDowsing() ||
hasTadtoneDowsing() || hasPropellerDowsing() || hasWaterBasinDowsing();
hasTadtoneDowsing() || hasPropellerDowsing() || hasWaterBasinDowsing();
} else if (slot == 2) {
return hasCrystalBallDowsing() || hasPumpkinDowsing() || hasNewPlantSpeciesDowsing() || hasKikwiDowsing() ||
hasKeyPieceDowsing() || hasDesertNodeDowsing() || hasPartyWheelDowsing();
hasKeyPieceDowsing() || hasDesertNodeDowsing() || hasPartyWheelDowsing();
} else if (StoryFlagManager::sInstance->getCounterOrFlag(DOWSING_TARGET_STORY_FLAGS[slot])) {
// TODO small instruction shuffle
return true;
@@ -146,8 +139,9 @@ bool DowsingTarget::hasDowsingInSlot(int slot) {
#define MYCLAMP(low, high, x) ((x) < (low) ? (low) : ((x) > (high) ? (high) : (x)))
DowsingTarget *DowsingTarget::getDowsingInfo(const mVec3_c &playerPosition, const mVec3_c &dowsingDirection, f32 *p3,
f32 *p4, f32 *intensity, int slot) {
DowsingTarget *DowsingTarget::getDowsingInfo(
const mVec3_c &playerPosition, const mVec3_c &dowsingDirection, f32 *p3, f32 *p4, f32 *intensity, int slot
) {
if (slot >= 8) {
return nullptr;
}
@@ -199,9 +193,9 @@ void DowsingTarget::init() {}
void DowsingTarget::execute() {}
// Not sure what this is
inline static TListNode *getNode(u8 slot, DowsingTarget *t) {
inline static TListNode<DowsingTarget> *getNode(u8 slot, DowsingTarget *t) {
if (t->mLink.mpNext == nullptr || t->mLink.mpPrev == nullptr) {
return &DOWSING_LISTS[slot].mNode;
return &DOWSING_LISTS[slot].mStartEnd;
} else {
return &t->mLink;
}
@@ -213,7 +207,7 @@ static bool insertDowsingTarget(DowsingTarget *target) {
return false;
}
if (getNode(slot, target) != &DOWSING_LISTS[slot].mNode) {
if (getNode(slot, target) != &DOWSING_LISTS[slot].mStartEnd) {
return false;
}
DOWSING_LISTS[slot].insert(target);
@@ -226,7 +220,7 @@ static bool removeDowsingTarget(DowsingTarget *target) {
return false;
}
if (getNode(slot, target) != &DOWSING_LISTS[slot].mNode) {
if (getNode(slot, target) != &DOWSING_LISTS[slot].mStartEnd) {
DOWSING_LISTS[slot].remove(target);
return true;
}