Skip to content

Commit

Permalink
d_particle work
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Sep 3, 2024
1 parent b227970 commit 893f6bc
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 81 deletions.
2 changes: 1 addition & 1 deletion include/JSystem/JParticle/JPAParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class JPABaseParticle {
JPABaseParticle() : mLink(this), mCurFrame(0.0f) {}
void setOffsetPosition(f32 x, f32 y, f32 z) { mGlobalPosition.set(x, y, z); }
void setOffsetPosition(const JGeometry::TVec3<f32>& pos) { mGlobalPosition.set(pos); }
void getOffsetPosition(JGeometry::TVec3<f32>& out) const { out.set(mPosition); } // XXX: something about this is wrong
void getGlobalPosition(JGeometry::TVec3<f32>& out) const { out.set(mGlobalPosition); }
s32 getAge() const { return mCurFrame; } // TODO: Not sure about this one, especially the cast to s32; this could also be mCurNormTime?
void calcCB(JPABaseEmitter* emtr) { if (mpCallBack2 != NULL) mpCallBack2->execute(emtr, this); }
Expand All @@ -59,7 +60,6 @@ class JPABaseParticle {
void getHeight() {}
void getLifeTime() const {}
void getLocalPosition(JGeometry::TVec3<f32>&) const {}
void getOffsetPosition(JGeometry::TVec3<f32>& out) const { out.set(mPosition); }
void getVelVec(JGeometry::TVec3<f32>&) const {}
void getWidth() {}
void setDeleteParticleFlag() {}
Expand Down
2 changes: 2 additions & 0 deletions include/SSystem/SComponent/c_bg_s.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "SSystem/SComponent/c_bg_s_poly_info.h"
#include "dolphin/types.h"

#define C_BG_INVALID_HEIGHT (-1e+9f)

class fopAc_ac_c;
class cBgS_ShdwDraw;
class cBgS_LinChk;
Expand Down
2 changes: 1 addition & 1 deletion include/d/d_bg_s.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class dBgS_CrrPos : public cBgS_PolyInfo, public dBgS_Chk, public cBgS_Chk {
mWallRadius = 0.0f;
pm_pos = NULL;
pm_old_pos = NULL;
mGroundH = -1e+9f;
mGroundH = C_BG_INVALID_HEIGHT;
field_0x60 = 0;
field_0x68 = 20.0f;
field_0x58 = NULL;
Expand Down
68 changes: 42 additions & 26 deletions include/d/d_particle.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ class dPa_followEcallBack : public dPa_levelEcallBack {
bool isEnd() { return mFlag & 1; }

/* 0x04 */ JPABaseEmitter* mpEmitter;
/* 0x08 */ u8 field_0x08[0x10 - 0x08];
/* 0x08 */ const cXyz* mPos;
/* 0x0C */ const csXyz* mAngle;
/* 0x10 */ u8 mFlag;
/* 0x11 */ u8 mRateOff;
/* 0x12 */ u8 field_0x12;
Expand Down Expand Up @@ -101,6 +102,8 @@ class dPa_simpleEcallBack : public JPACallBackBase<JPABaseEmitter*> {
JPABaseEmitter* createEmitter(JPAEmitterManager*);
bool set(cXyz const*, u8, GXColor const&, GXColor const&, int);

u16 getID() { return mResID; }

/* 0x004 */ JPABaseEmitter* mpBaseEmitter;
/* 0x008 */ u16 mResID;
/* 0x00A */ u8 mGrpID;
Expand Down Expand Up @@ -354,6 +357,20 @@ class dPa_control_c {
public:
dPa_control_c();

enum {
dPtclGroup_Normal_e,
dPtclGroup_NormalP1_e,
dPtclGroup_Toon_e,
dPtclGroup_ToonP1_e,
dPtclGroup_Projection_e,
dPtclGroup_ShipTail_e,
dPtclGroup_Wind_e,
dPtclGroup_2Dfore_e,
dPtclGroup_2Dback_e,
dPtclGroup_2DmenuFore_e,
dPtclGroup_2DmenuBack_e,
};

static u8 getRM_ID(u16);
void swapFrameBufferTexture();
void createCommon(void const*);
Expand All @@ -369,11 +386,10 @@ class dPa_control_c {
JPABaseEmitter* set(u8, u16, cXyz const*, csXyz const*, cXyz const*, u8, dPa_levelEcallBack*,
s8, GXColor const*, GXColor const*, cXyz const*);
JPABaseEmitter* setBombSmoke(u16, cXyz const*, csXyz const*, cXyz const*, u8);
void setSimpleLand(int, cXyz const*, csXyz const*, f32, f32, f32, dKy_tevstr_c*, int*, int);
void setSimpleLand(cBgS_PolyInfo&, cXyz const*, csXyz const*, f32, f32, f32, dKy_tevstr_c*,
int*, int);
JPABaseEmitter* setSimpleLand(int, cXyz const*, csXyz const*, f32, f32, f32, dKy_tevstr_c*, int*, int);
JPABaseEmitter* setSimpleLand(cBgS_PolyInfo&, cXyz const*, csXyz const*, f32, f32, f32, dKy_tevstr_c*, int*, int);
s32 checkAtrCodeEffect(int);
void setNormalStripes(u16, cXyz const*, csXyz const*, cXyz const*, u8, u16);
JPABaseEmitter* setNormalStripes(u16, cXyz const*, csXyz const*, cXyz const*, u8, u16);
bool newSimple(u16, u8);
bool setSimple(u16, cXyz const*, u8, GXColor const&, GXColor const&, int);
dPa_simpleEcallBack* getSimple(u16);
Expand All @@ -382,72 +398,72 @@ class dPa_control_c {
const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack,
s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor,
const cXyz* pScale2D) {
return set(0, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
return set(dPtclGroup_Normal_e, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
}
JPABaseEmitter* setNormalP1(u16 particleID, const cXyz* pos, const csXyz* angle,
const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack,
s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor,
const cXyz* pScale2D) {
return set(1, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
return set(dPtclGroup_NormalP1_e, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
}
JPABaseEmitter* setToon(u16 particleID, const cXyz* pos, const csXyz* angle,
const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack,
s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor,
const cXyz* pScale2D) {
return set(2, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
return set(dPtclGroup_Toon_e, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
}
JPABaseEmitter* setToonP1(u16 particleID, const cXyz* pos, const csXyz* angle,
const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack,
s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor,
const cXyz* pScale2D) {
return set(3, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
return set(dPtclGroup_ToonP1_e, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
}
JPABaseEmitter* setProjection(u16 particleID, const cXyz* pos, const csXyz* angle,
const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack,
s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor,
const cXyz* pScale2D) {
return set(4, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
return set(dPtclGroup_Projection_e, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
}
JPABaseEmitter* setShipTail(u16 particleID, const cXyz* pos, const csXyz* angle,
const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack,
s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor,
const cXyz* pScale2D) {
return set(5, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
return set(dPtclGroup_ShipTail_e, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
}
JPABaseEmitter* set2Dfore(u16 particleID, const cXyz* pos, const csXyz* angle,
const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack,
s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor,
const cXyz* pScale2D) {
return set(7, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
return set(dPtclGroup_2Dfore_e, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
}
JPABaseEmitter* set2Dback(u16 particleID, const cXyz* pos, const csXyz* angle,
const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack,
s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor,
const cXyz* pScale2D) {
return set(8, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
return set(dPtclGroup_2Dback_e, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
}
JPABaseEmitter* set2DmenuFore(u16 particleID, const cXyz* pos, const csXyz* angle,
const cXyz* scale, u8 alpha, dPa_levelEcallBack* pCallBack,
s8 setupInfo, const GXColor* pPrmColor, const GXColor* pEnvColor,
const cXyz* pScale2D) {
return set(9, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
return set(dPtclGroup_2DmenuFore_e, particleID, pos, angle, scale, alpha, pCallBack, setupInfo, pPrmColor, pEnvColor, pScale2D);
}
JPABaseEmitter* setSingleRipple(u16 particleID, const cXyz* pos, const csXyz* angle,
const cXyz* scale, u8 alpha) {
return set(5, particleID, pos, angle, scale, alpha, &mSingleRippleEcallBack, -1, NULL, NULL, NULL);
return set(dPtclGroup_ShipTail_e, particleID, pos, angle, scale, alpha, &mSingleRippleEcallBack, -1, NULL, NULL, NULL);
}

void draw(JPADrawInfo* inf) { draw(inf, 0); }
void drawP1(JPADrawInfo* inf) { draw(inf, 1); }
void drawToon(JPADrawInfo* inf) { draw(inf, 2); }
void drawToonP1(JPADrawInfo* inf) { draw(inf, 3); }
void drawProjection(JPADrawInfo* inf) { draw(inf, 4); }
void drawShipTail(JPADrawInfo* inf) { draw(inf, 5); }
void drawWind(JPADrawInfo* inf) { draw(inf, 6); }
void draw2Dfore(JPADrawInfo* inf) { draw(inf, 7); }
void draw2Dback(JPADrawInfo* inf) { draw(inf, 8); }
void draw2DmenuFore(JPADrawInfo* inf) { draw(inf, 9); }
void draw2DmenuBack(JPADrawInfo* inf) { draw(inf, 10); }
void draw(JPADrawInfo* inf) { draw(inf, dPtclGroup_Normal_e); }
void drawP1(JPADrawInfo* inf) { draw(inf, dPtclGroup_NormalP1_e); }
void drawToon(JPADrawInfo* inf) { draw(inf, dPtclGroup_Toon_e); }
void drawToonP1(JPADrawInfo* inf) { draw(inf, dPtclGroup_ToonP1_e); }
void drawProjection(JPADrawInfo* inf) { draw(inf, dPtclGroup_Projection_e); }
void drawShipTail(JPADrawInfo* inf) { draw(inf, dPtclGroup_ShipTail_e); }
void drawWind(JPADrawInfo* inf) { draw(inf, dPtclGroup_Wind_e); }
void draw2Dfore(JPADrawInfo* inf) { draw(inf, dPtclGroup_2Dfore_e); }
void draw2Dback(JPADrawInfo* inf) { draw(inf, dPtclGroup_2Dfore_e); }
void draw2DmenuFore(JPADrawInfo* inf) { draw(inf, dPtclGroup_2DmenuFore_e); }
void draw2DmenuBack(JPADrawInfo* inf) { draw(inf, dPtclGroup_2DmenuBack_e); }

u32 getParticleNum() { return mEmitterMng->getParticleNumber(); }
u32 getEmitterNum() { return mEmitterMng->getEmitterNumber(); }
Expand Down
2 changes: 1 addition & 1 deletion src/SSystem/SComponent/c_bg_s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool cBgS::LineCross(cBgS_LinChk* chk) {

/* 802468E4-80246A14 .text GroundCross__4cBgSFP11cBgS_GndChk */
f32 cBgS::GroundCross(cBgS_GndChk* chk) {
chk->SetNowY(-1e+09f);
chk->SetNowY(C_BG_INVALID_HEIGHT);
chk->ClearPi();
chk->mWallPrecheck = (chk->mFlag & 0x02);
chk->mGndPrecheck = (chk->mFlag & 0x01);
Expand Down
2 changes: 1 addition & 1 deletion src/d/actor/d_a_agb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ void daAgb_c::CursorMove(fopAc_ac_c* actor, u32 stage_type) {

cXyz r1_14;
dBgS_GndChk r1_5C;
f32 f30 = -1e+9f;
f32 f30 = C_BG_INVALID_HEIGHT;
r1_5C.OffWall();
r1_14.y = actor->current.pos.y + 150.0f;
static f32 l_ckOffset[][2] = {
Expand Down
2 changes: 1 addition & 1 deletion src/d/d_lib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void dLib_setCirclePath(dLib_circle_path_c* path) {
/* 800570CC-8005716C .text dLib_getWaterY__FR4cXyzR12dBgS_ObjAcch */
f32 dLib_getWaterY(cXyz& pos, dBgS_ObjAcch& acch) {
BOOL waterHit = acch.ChkWaterHit();
f32 waterHeight = waterHit ? acch.m_wtr.GetHeight() : -1e+09f;
f32 waterHeight = waterHit ? acch.m_wtr.GetHeight() : C_BG_INVALID_HEIGHT;
if (daSea_ChkArea(pos.x, pos.z)) {
f32 seaHeight = daSea_calcWave(pos.x, pos.z);
if (!waterHit || seaHeight > waterHeight) {
Expand Down
2 changes: 1 addition & 1 deletion src/d/d_magma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void dMagma_packet_c::update() {
/* 800767E4-80076924 .text checkYpos__15dMagma_packet_cFR4cXyz */
f32 dMagma_packet_c::checkYpos(cXyz& pos) {
/* Nonmatching */
f32 ret = -100000000.0f;
f32 ret = C_BG_INVALID_HEIGHT;
dMagma_floor_c* floor = mFloor;
for (s32 i = 0; i < (s32)ARRAY_SIZE(mFloor); floor++, i++) {
if (floor->mpBalls == NULL)
Expand Down
Loading

0 comments on commit 893f6bc

Please sign in to comment.