Skip to content

Commit

Permalink
use better collision functions in bombf
Browse files Browse the repository at this point in the history
  • Loading branch information
robojumper committed Oct 26, 2024
1 parent 10cfb27 commit 43cb35f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 17 deletions.
26 changes: 17 additions & 9 deletions include/m/m_mtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class mMtx_c : public EGG::Matrix34f {
typedef const f32 (*MtxRefConst)[4];

public:
mMtx_c(){};
mMtx_c() {};
mMtx_c(f32 xx, f32 xy, f32 xz, f32 xw, f32 yx, f32 yy, f32 yz, f32 yw, f32 zx, f32 zy, f32 zz, f32 zw);

operator MtxRef() {
Expand All @@ -37,15 +37,23 @@ class mMtx_c : public EGG::Matrix34f {
void ZrotS(const mAng &angle); ///< Generates a rotation matrix for the Z axis with the given angle.
void ZrotM(const mAng &angle); ///< Rotates the matrix on the Z axis by the given angle.

void ZXYrotS(mAng xRot, mAng yRot,
mAng zRot); ///< Generates the matrix on the Y, X and Z axes by the given angles.
void ZXYrotM(mAng xRot, mAng yRot,
mAng zRot); ///< Rotates the matrix on the Y, X and Z axes by the given angles.
void XYZrotS(mAng xRot, mAng yRot,
mAng zRot); ///< Generates the matrix on the Z, Y and X axes by the given angles.
void ZXYrotS(
const mAng &xRot, const mAng &yRot,
const mAng &zRot
); ///< Generates the matrix on the Y, X and Z axes by the given angles.
void ZXYrotM(
const mAng &xRot, const mAng &yRot,
const mAng &zRot
); ///< Rotates the matrix on the Y, X and Z axes by the given angles.
void XYZrotS(
const mAng &xRot, const mAng &yRot,
const mAng &zRot
); ///< Generates the matrix on the Z, Y and X axes by the given angles.

void XYZrotM(mAng xRot, mAng yRot,
mAng zRot); ///< Rotates the matrix on the Z, Y and X axes by the given angles.
void XYZrotM(
const mAng &xRot, const mAng &yRot,
const mAng &zRot
); ///< Rotates the matrix on the Z, Y and X axes by the given angles.

void toRot(mAng3_c &out) const; ///< Converts the matrix to a rotation vector.

Expand Down
46 changes: 38 additions & 8 deletions src/REL/d/a/d_a_bombf.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include "d/a/d_a_bombf.h"

#include "common.h"
#include "d/a/d_a_player.h"
#include "d/col/bg/d_bg_s.h"
#include "egg/math/eggMatrix.h"
#include "d/col/bg/d_bg_s_lin_chk.h"
#include "m/m_mtx.h"
#include "m/m_vec.h"
#include "toBeSorted/sceneflag_manager.h"
#include "toBeSorted/time_area_mgr.h"

SPECIAL_ACTOR_PROFILE(BOMBF, dAcBombf_c, fProfile::BOMBF, 0x129, 0, 4099);

Expand Down Expand Up @@ -44,9 +47,6 @@ int dAcBombf_c::actorCreate() {
return SUCCEEDED;
}

extern "C" bool fn_803421C0(const mVec3_c &, const mVec3_c &, dAcObjBase_c *);
extern "C" mVec3_c lbl_805D02D8;
extern "C" bool fn_80342300();

int dAcBombf_c::actorPostCreate() {
mMtx_c mtx;
Expand All @@ -57,11 +57,41 @@ int dAcBombf_c::actorPostCreate() {
mVec3_c v3 = position + v1;
mVec3_c v4 = position - v1;

if (fn_803421C0(v3, v4, this)) {
position = lbl_805D02D8;
if (rotation.x == 0 && rotation.z == 0 && fn_80342300()) {
// TODO

if (dBgS_ObjLinChk::LineCross(&v3, &v4, this)) {
dBgS_ObjLinChk &chk = dBgS_ObjLinChk::GetInstance();
position = chk.GetLinEnd();
if (rotation.x == 0 && rotation.z == 0 && dBgS_ObjLinChk::ChkGround()) {
cM3dGPla pla;
dBgS::GetInstance()->GetTriPla(chk, &pla);
rotation.x = pla.GetAngle(rotation.y);
rotation.z = pla.GetAngle(rotation.x - 0x4000);
}

if (dBgS::GetInstance()->ChkMoveBG(dBgS_ObjLinChk::GetInstance(), false)) {
field_0x398.SetPolyInfo(dBgS_ObjLinChk::GetInstance());
actor_properties = (actor_properties & ~1) | 4;
}
mLightingInfo.mLightingCode = dBgS::GetInstance()->GetLightingCode(dBgS_ObjLinChk::GetInstance());

if (field_0x3D2 == 0 || field_0x3D2 == 2) {
bool b = dTimeAreaMgr_c::sInstance->fn_800B9B60(roomid, position);
// TODO more conditions, weird control flow
if (b && field_0x3D2 == 0) {
mModel.setScale(0.0001f, 0.0001f, 0.0001f);
if (mBombRef.get() != nullptr) {
// TODO wrong field
mBombRef.get()->mScale.x = 0.0001f;
}
}
}
}

updateMatrix();
mModel.setLocalMtx(mWorldMtx);
regrowBomb();
if (mBombRef.get() != nullptr) {
mBombRef.get()->mScale.set(0.95f, 0.95f, 0.95f);
}

return SUCCEEDED;
Expand Down

0 comments on commit 43cb35f

Please sign in to comment.