mirror of
https://github.com/zeldaret/ss
synced 2026-07-04 20:55:29 -04:00
Rough dynamic collision setup (#24)
* Rough collider shape setup * d_a_obj_toD3_stone_figure OK * Cleanup * Cleanup 2
This commit is contained in:
@@ -48,7 +48,7 @@ int dAcOPoolCock_c::actorExecute() {
|
||||
mStateMgr.executeState();
|
||||
calcVelocity();
|
||||
position += velocity;
|
||||
position += posIncrements;
|
||||
position += mCCdStruct.posIncrements;
|
||||
updateMatrix();
|
||||
mMtx_c mdl1Transform;
|
||||
mMtx_c mdl2Transform;
|
||||
|
||||
@@ -37,7 +37,7 @@ int dAcOring_c::actorExecute() {
|
||||
mStateMgr.executeState();
|
||||
calcVelocity();
|
||||
position += velocity;
|
||||
position += posIncrements;
|
||||
position += mCCdStruct.posIncrements;
|
||||
updateMatrix();
|
||||
mModel.setLocalMtx(worldMatrix);
|
||||
return SUCCEEDED;
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
#include <d/a/obj/d_a_obj_spike.h>
|
||||
#include <toBeSorted/cc/d_cc_mgr.h>
|
||||
|
||||
SPECIAL_ACTOR_PROFILE(OBJ_SPIKE, dAcOspike_c, fProfile::OBJ_SPIKE, 0x1D9, 0, 2);
|
||||
|
||||
// clang-format off
|
||||
dCcD_SrcAabb dAcOspike_c::sCcSrc = {
|
||||
{{{0x400}, 0x2003F, 0, 1, 0, 0, 0, 0, 0},
|
||||
{{0xFEB77DFF}, 0x111, 0x60407, 0, 0},
|
||||
{0}},
|
||||
{-1.0f, -246.0f, -472.0f, 73.0f, 255.0f, 482.0f}};
|
||||
// clang-format on
|
||||
|
||||
const mVec3_c dAcOspike_c::sVec1 = mVec3_c(-1.0f, -246.0f, -472.0f);
|
||||
const mVec3_c dAcOspike_c::sVec2 = mVec3_c(73.0f, 255.0f, 482.0f);
|
||||
|
||||
STATE_DEFINE(dAcOspike_c, Wait);
|
||||
|
||||
bool dAcOspike_c::createHeap() {
|
||||
mResFile = getOarcResFile("SpikeD101");
|
||||
nw4r::g3d::ResMdl mdl = mResFile.GetResMdl("SpikeD101");
|
||||
TRY_CREATE(mMdl.create(mdl, &heap_allocator, 0x120));
|
||||
return true;
|
||||
}
|
||||
|
||||
int dAcOspike_c::create() {
|
||||
if (!initAllocatorWork1Heap(-1, "dAcOspike_c::m_allocator", 0x20)) {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
mCCdStruct.setField0x38ToMagicValue();
|
||||
mCollision.init(sCcSrc);
|
||||
mCollision.initUnk(mCCdStruct);
|
||||
|
||||
updateMatrix();
|
||||
mMdl.setLocalMtx(worldMatrix);
|
||||
mVec3_c tmp;
|
||||
PSMTXMultVecSR(worldMatrix.m, mVec3_c::Ex, tmp);
|
||||
mCollision.setAtVec(tmp);
|
||||
|
||||
mMtx_c mtx;
|
||||
mtx.XrotS(rotation.x);
|
||||
mtx.ZrotM(rotation.z);
|
||||
mVec3_c tmp2, tmp3;
|
||||
PSMTXMultVecSR(mtx.m, sVec1, tmp2);
|
||||
PSMTXMultVecSR(mtx.m, sVec2, tmp3);
|
||||
|
||||
if (tmp2.x > tmp3.x) {
|
||||
f32 copy = tmp2.x;
|
||||
tmp2.x = tmp3.x;
|
||||
tmp3.x = copy;
|
||||
}
|
||||
if (tmp2.y > tmp3.y) {
|
||||
f32 copy = tmp2.y;
|
||||
tmp2.y = tmp3.y;
|
||||
tmp3.y = copy;
|
||||
}
|
||||
if (tmp2.z > tmp3.z) {
|
||||
f32 copy = tmp2.z;
|
||||
tmp2.z = tmp3.z;
|
||||
tmp3.z = copy;
|
||||
}
|
||||
|
||||
mCollision.setMinMax(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;
|
||||
}
|
||||
|
||||
int dAcOspike_c::doDelete() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dAcOspike_c::actorExecute() {
|
||||
mStateMgr.executeState();
|
||||
mCollision.setWithYRot(position, rotation.y);
|
||||
ColliderManager::getColliderManager()->addCollider(&mCollision);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dAcOspike_c::draw() {
|
||||
drawModelType1(&mMdl);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void dAcOspike_c::initializeState_Wait() {}
|
||||
void dAcOspike_c::executeState_Wait() {}
|
||||
void dAcOspike_c::finalizeState_Wait() {}
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
#include <d/a/obj/d_a_obj_toD3_stone_figure.h>
|
||||
#include <toBeSorted/attention.h>
|
||||
#include <toBeSorted/cc/d_cc_mgr.h>
|
||||
#include <toBeSorted/event.h>
|
||||
#include <toBeSorted/event_manager.h>
|
||||
#include <toBeSorted/scgame.h>
|
||||
#include <toBeSorted/item_story_flag_manager.h>
|
||||
|
||||
SPECIAL_ACTOR_PROFILE(OBJ_TOD3_STONE, dAcOtoD3StoneFigure_c, fProfile::OBJ_TOD3_STONE, 0x1B3, 0, 0);
|
||||
|
||||
STATE_DEFINE(dAcOtoD3StoneFigure_c, OneEye);
|
||||
STATE_DEFINE(dAcOtoD3StoneFigure_c, Eyes);
|
||||
|
||||
f32 dAcOtoD3StoneFigure_c::sRadius = 85.0f;
|
||||
f32 dAcOtoD3StoneFigure_c::sHeight = 290.0f;
|
||||
|
||||
// clang-format off
|
||||
dCcD_SrcCyl dAcOtoD3StoneFigure_c::sCcSrc = {
|
||||
{{{0}, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{{0xFEB77DFF}, 0x1000111, 0x60407, 0, 0},
|
||||
{0xE9}},
|
||||
{dAcOtoD3StoneFigure_c::sRadius, dAcOtoD3StoneFigure_c::sHeight}
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
bool dAcOtoD3StoneFigure_c::createHeap() {
|
||||
const char *modelName = getModelName();
|
||||
mResFile = getOarcResFile("BirdObjD3");
|
||||
nw4r::g3d::ResMdl mdl = mResFile.GetResMdl(modelName);
|
||||
TRY_CREATE(mMdl.create(mdl, &heap_allocator, 0x120));
|
||||
return true;
|
||||
}
|
||||
|
||||
int dAcOtoD3StoneFigure_c::create() {
|
||||
mIsSkyKeepAlreadyOpen = isStoneOfTrialsPlaced();
|
||||
mExitId = params & 0xFF;
|
||||
updateMatrix();
|
||||
if (!initAllocatorWork1Heap(-1, "dAcOtoD3StoneFigure_c::m_allocator", 0x20)) {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
mMdl.setLocalMtx(worldMatrix);
|
||||
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);
|
||||
ColliderManager::getColliderManager()->addCollider(&mCollision);
|
||||
// mCollision.clearCoFlag();
|
||||
mCollision.setTgCoFlag(1);
|
||||
|
||||
// ???
|
||||
f32 a, b, c;
|
||||
c = position.z;
|
||||
b = getYPos();
|
||||
b += zero;
|
||||
a = position.x;
|
||||
poscopy2.x = a;
|
||||
poscopy2.y = b;
|
||||
poscopy2.z = c;
|
||||
poscopy3.x = a;
|
||||
poscopy3.y = b;
|
||||
poscopy3.z = c;
|
||||
// poscopy3 = poscopy2;
|
||||
mCollision.setSomeDefendValue(0x2000);
|
||||
|
||||
if (!mIsSkyKeepAlreadyOpen) {
|
||||
mStateMgr.changeState(StateID_OneEye);
|
||||
} else {
|
||||
mStateMgr.changeState(StateID_Eyes);
|
||||
}
|
||||
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
int dAcOtoD3StoneFigure_c::doDelete() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dAcOtoD3StoneFigure_c::actorExecute() {
|
||||
mStateMgr.executeState();
|
||||
ColliderManager::getColliderManager()->addCollider(&mCollision);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dAcOtoD3StoneFigure_c::draw() {
|
||||
if (ScGame::currentSpawnInfo.layer != 0x12) {
|
||||
drawModelType1(&mMdl);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void dAcOtoD3StoneFigure_c::initializeState_OneEye() {
|
||||
if (ScGame::currentSpawnInfo.night == 1) {
|
||||
rotation.y.mVal += -0x8000;
|
||||
updateMatrix();
|
||||
mMdl.setLocalMtx(worldMatrix);
|
||||
}
|
||||
}
|
||||
|
||||
void dAcOtoD3StoneFigure_c::executeState_OneEye() {
|
||||
if (EventManager::isInEvent(this, "D3OpenStart")) {
|
||||
ScGame::sInstance->triggerExit(roomid, mExitId);
|
||||
} else {
|
||||
if (hasStoneOfTrials() && ScGame::currentSpawnInfo.night != 1) {
|
||||
// These are interaction related
|
||||
-0.0f;
|
||||
dAttention_c::sInstance->addTarget(this, 1, 300.0f, 50.0f, -100.0f, 100.0f);
|
||||
dAttention_c::sInstance->addTarget(this, 1, 200.0f, -100.0f, 100.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
void dAcOtoD3StoneFigure_c::finalizeState_OneEye() {}
|
||||
|
||||
void dAcOtoD3StoneFigure_c::initializeState_Eyes() {}
|
||||
void dAcOtoD3StoneFigure_c::executeState_Eyes() {}
|
||||
void dAcOtoD3StoneFigure_c::finalizeState_Eyes() {}
|
||||
|
||||
const char *dAcOtoD3StoneFigure_c::getModelName() const {
|
||||
return mIsSkyKeepAlreadyOpen ? "BirdObjD3B" : "BirdObjD3A";
|
||||
}
|
||||
|
||||
bool dAcOtoD3StoneFigure_c::isStoneOfTrialsPlaced() const {
|
||||
return StoryFlagManager::sInstance->getCounterOrFlag(22);
|
||||
}
|
||||
|
||||
void dAcOtoD3StoneFigure_c::doInteraction(s32 arg) {
|
||||
if (arg == 5) {
|
||||
Event event = Event("D3OpenStart", 100, 0x100001, nullptr, nullptr);
|
||||
EventManager::alsoSetAsCurrentEvent(this, &event, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" s32 fn_80251B70(s32);
|
||||
bool dAcOtoD3StoneFigure_c::hasStoneOfTrials() const {
|
||||
return fn_80251B70(0xB4);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#include <c/c_math.h>
|
||||
#include <d/a/obj/d_a_obj_triforce.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);
|
||||
|
||||
// clang-format off
|
||||
dCcD_SrcSph dAcOtriforce_c::sCcSrc = {
|
||||
{{{0}, 0, 0, 0, 0, 0, 0, 0, 0},
|
||||
{{0xFEB77DFF}, 0x111, 0x60407, 0, 0},
|
||||
{0xE9}},
|
||||
{150.0f}};
|
||||
// clang-format on
|
||||
|
||||
const f32 dAcOtriforce_c::sScale = 6.5f;
|
||||
const f32 dAcOtriforce_c::sAmpNeg = -3.0f;
|
||||
const u32 dAcOtriforce_c::sStartingOffsetRange = 0x10000;
|
||||
|
||||
// const f32 dAcOtriforce_c::sAmpPos = 23.0f;
|
||||
|
||||
bool dAcOtriforce_c::createHeap() {
|
||||
mResFile = getOarcResFile("TriForce");
|
||||
nw4r::g3d::ResMdl mdl = mResFile.GetResMdl("TriForce");
|
||||
TRY_CREATE(mMdl.create(mdl, &heap_allocator, 0x324));
|
||||
nw4r::g3d::ResAnmTexSrt anm = mResFile.GetResAnmTexSrt("TriForce");
|
||||
TRY_CREATE(mAnm.create(mdl, anm, &heap_allocator, nullptr, 1));
|
||||
mMdl.setAnm(mAnm);
|
||||
return true;
|
||||
}
|
||||
|
||||
int dAcOtriforce_c::create() {
|
||||
if (!initAllocatorWork1Heap(-1, "dAcOtriforce_c::m_allocator", 0x20)) {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
mCCdStruct.setField0x38ToMagicValue();
|
||||
mCollision.init(sCcSrc);
|
||||
mCollision.initUnk(mCCdStruct);
|
||||
mCollision.clearCoFlag();
|
||||
mStartingOffset = cM::rndInt(sStartingOffsetRange);
|
||||
mEffects.init(this);
|
||||
mCollision.setSomeDefendValue(0x2000);
|
||||
updateMatrix();
|
||||
scale.x = sScale;
|
||||
scale.y = sScale;
|
||||
scale.z = sScale;
|
||||
mMdl.setLocalMtx(worldMatrix);
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
int dAcOtriforce_c::doDelete() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern const u16 lbl_8057AB3E;
|
||||
extern "C" void fn_80029AE0(EffectsStruct *, u16, mMtx_c *, void *, void *);
|
||||
|
||||
int dAcOtriforce_c::actorExecute() {
|
||||
int zero = 0;
|
||||
mVec3_c offset = mVec3_c::Ey * (mStartingOffset.sin() * getBounceScalar());
|
||||
position = mStartingPos + offset;
|
||||
mStartingOffset.mVal += 0x16C;
|
||||
|
||||
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);
|
||||
mAnm.play();
|
||||
fn_80029AE0(&mEffects, lbl_8057AB3E, &worldMatrix, nullptr, nullptr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dAcOtriforce_c::draw() {
|
||||
drawModelType1(&mMdl);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ void float_ordering() {
|
||||
0.01f;
|
||||
}
|
||||
|
||||
|
||||
int dTgSndAr_c::create() {
|
||||
scale *= 0.01f;
|
||||
if (dTgSndMg_c::sInstance == nullptr) {
|
||||
@@ -34,9 +33,8 @@ int dTgSndAr_c::create() {
|
||||
if ((base = fManager_c::searchBaseByGroupType(ACTOR, base)) == nullptr) {
|
||||
break;
|
||||
}
|
||||
// This has got to be just a member function
|
||||
dAcBase_c *ac = static_cast<dAcBase_c *>(base);
|
||||
if (!dBase_c::isActorPlayer(*ac) && checkPosInArea(ac->position)) {
|
||||
if (!ac->isActorPlayer() && checkPosInArea(ac->position)) {
|
||||
ac->setBit_field_0xE8(params & 0xFF);
|
||||
}
|
||||
}
|
||||
@@ -142,26 +140,31 @@ struct UnkStruct {
|
||||
|
||||
extern "C" void fn_80337EA0(UnkStruct *);
|
||||
extern "C" void fn_80337EF0(UnkStruct *, mVec3_c &, mVec3_c &, f32);
|
||||
extern "C" int fn_8032BFB0(UnkStruct *, EGG::Vector3f &, f32 *, f32 &, int);
|
||||
extern "C" int cM3d_Len3dSqPntAndSegLine(UnkStruct *, Vec &, Vec *, f32 *, f32 *);
|
||||
|
||||
// ???
|
||||
// Capsule
|
||||
bool dTgSndAr_c::checkAlg3(const mVec3_c &pos) {
|
||||
f32 q[4];
|
||||
UnkStruct unk;
|
||||
Vec q;
|
||||
|
||||
f32 radius = scale.x * 100.0f;
|
||||
radius = radius * radius;
|
||||
EGG::Vector3f a = pos;
|
||||
Vec a = pos;
|
||||
|
||||
UnkStruct unk;
|
||||
fn_80337EA0(&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);
|
||||
f32 d;
|
||||
if (fn_8032BFB0(&unk, a, q, d, 0)) {
|
||||
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);
|
||||
if (distSq < radius) {
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user