This commit is contained in:
Jasper St. Pierre
2024-07-14 20:30:36 -07:00
parent af11fc739c
commit bae8aa63bc
8 changed files with 63 additions and 73 deletions
+4 -3
View File
@@ -266,6 +266,8 @@ public:
stopCreateParticle();
}
bool isZDraw() { return mDraw.isZDraw(); }
void setEmitterCallBackPtr(JPACallBackBase<JPABaseEmitter*>* callback) {
mpEmitterCallBack = callback;
}
@@ -274,6 +276,8 @@ public:
}
void setParticleList(JSUList<JPABaseParticle>* list) { mpPtclVacList = list; }
void setFieldList(JSUList<JPAFieldData>* list) { mFieldManager.mVacList = list; }
JSUList<JPABaseParticle>* getParticleList() { return &mActiveParticles; }
JSUList<JPABaseParticle>* getChildParticleList() { return &mChildParticles; }
JSULink<JPABaseEmitter>* getLinkBufferPtr() { return &mLink; }
void initDrawMgr(JPATextureResource* texRes) { mDraw.initialize(this, texRes); }
void draw(MtxP cameraMtxP) { mDraw.draw(cameraMtxP); }
@@ -294,15 +298,12 @@ public:
void getBaseEnvColor(GXColor&) {}
void getBasePrmColor(GXColor&) {}
void getCamMtxPtr() {}
JSUList<JPABaseParticle>* getChildParticleList() { return &mChildParticles; }
void getCurrentCreateNumber() const {}
void getFrame() {}
void getGlobalParticleScale(JGeometry::TVec3<f32>&) const {}
JSUList<JPABaseParticle>* getParticleList() { return &mActiveParticles; }
void getgReRDirection(JGeometry::TVec3<f32>&) {}
void isChildDraw() {}
void isContinuousParticle() {}
bool isZDraw() { return mDraw.isZDraw(); }
void loadTexture(u8, GXTexMapID) {}
void setEmitterRotation(const JGeometry::TVec3<s16>&) {}
void setGlobalParticleHeightScale(f32) {}
+11 -9
View File
@@ -22,6 +22,8 @@ template<typename T, typename U>
class JPACallBackBase2;
enum JPAParticleStatus {
JPAPtclStts_FirstFrame = 0x01,
JPAPtlcStts_Child = 0x04,
JPAPtclStts_Invisible = 0x08,
};
@@ -40,15 +42,18 @@ public:
void setOffsetPosition(f32 x, f32 y, f32 z) { mGlobalPosition.set(x, y, z); }
void setOffsetPosition(const JGeometry::TVec3<f32>& pos) { mGlobalPosition.set(pos); }
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); }
void drawCB(JPABaseEmitter* emtr) { if (mpCallBack2 != NULL) mpCallBack2->draw(emtr, this); }
void setCallBackPtr(JPACallBackBase2<JPABaseEmitter*, JPABaseParticle*>* cb) { mpCallBack2 = cb; }
bool checkStatus(u32 flag) { return mStatus & flag; }
void initStatus(u32 flag) { mStatus = flag; }
void setStatus(u32 flag) { mStatus |= flag; }
void clearStatus(u32 flag) { mStatus &= ~flag; }
bool isInvisibleParticle() { return checkStatus(JPAPtclStts_Invisible); }
void setInvisibleParticleFlag() { mStatus |= JPAPtclStts_Invisible; }
void setInvisibleParticleFlag() { setStatus(JPAPtclStts_Invisible); }
void calcCB(JPABaseEmitter*) {}
void clearStatus(u32) {}
void drawCB(JPABaseEmitter*) {}
void getAge() const {}
void getDrawParamCPtr() {}
void getDrawParamPPtr() {}
void getHeight() {}
@@ -57,10 +62,7 @@ public:
void getOffsetPosition(JGeometry::TVec3<f32>&) const {}
void getVelVec(JGeometry::TVec3<f32>&) const {}
void getWidth() {}
void initStatus(u32) {}
void setCallBackPtr(JPACallBackBase2<JPABaseEmitter*, JPABaseParticle*>*) {}
void setDeleteParticleFlag() {}
void setStatus(u32) {}
public:
/* 0x00 */ JSULink<JPABaseParticle> mLink;
@@ -91,7 +93,7 @@ public:
/* 0xBC */ GXColor mEnvColor;
/* 0xC0 */ u16 mRotateAngle;
/* 0xC2 */ s16 mRotateSpeed;
/* 0xC4 */ u8 field_0xC4[0xC6 - 0xC4];
/* 0xC4 */ u16 field_0xC4;
/* 0xC6 */ u16 mTexIdx;
/* 0xC8 */ JPACallBackBase2<JPABaseEmitter*, JPABaseParticle*>* mpCallBack2;
/* 0xCC */ u32 mStatus;
+5 -10
View File
@@ -810,8 +810,7 @@ void JPADrawExecCallBack::exec(const JPADrawContext* pDC) {
/* 80264C4C-80264C88 .text exec__19JPADrawExecCallBackFPC14JPADrawContextP15JPABaseParticle */
void JPADrawExecCallBack::exec(const JPADrawContext* pDC, JPABaseParticle* ptcl) {
JPABaseEmitter* pbe = pDC->pbe;
if (ptcl->mpCallBack2 != NULL)
ptcl->mpCallBack2->draw(pbe, ptcl);
ptcl->drawCB(pbe);
}
/* 80264C88-80264DB8 .text calc__17JPADrawCalcScaleXFPC14JPADrawContextP15JPABaseParticle */
@@ -890,19 +889,15 @@ void JPADrawCalcScaleAnmTimingRepeatY::calc(const JPADrawContext* pDC, JPABasePa
/* 80265444-80265588 .text calc__33JPADrawCalcScaleAnmTimingReverseXFPC14JPADrawContextP15JPABaseParticle */
void JPADrawCalcScaleAnmTimingReverseX::calc(const JPADrawContext* pDC, JPABaseParticle* ptcl) {
s32 curFrame = ptcl->mCurFrame;
f32 odd = ((s32)curFrame / pDC->pesp->getAnmCycleX()) & 1; // whether we're on an even or odd loop
curFrame = ptcl->mCurFrame; // fakematch; probably an inline function (getAge?)
f32 frame = (f32)((s32)curFrame % pDC->pesp->getAnmCycleX()) / pDC->pesp->getAnmCycleX();
f32 odd = (ptcl->getAge() / pDC->pesp->getAnmCycleX()) & 1; // whether we're on an even or odd loop
f32 frame = (f32)(ptcl->getAge() % pDC->pesp->getAnmCycleX()) / pDC->pesp->getAnmCycleX();
JPADrawContext::pcb->mScaleAnmTiming = odd + (frame - odd * 2.0f * frame);
}
/* 80265588-802656CC .text calc__33JPADrawCalcScaleAnmTimingReverseYFPC14JPADrawContextP15JPABaseParticle */
void JPADrawCalcScaleAnmTimingReverseY::calc(const JPADrawContext* pDC, JPABaseParticle* ptcl) {
s32 curFrame = ptcl->mCurFrame;
f32 odd = ((s32)curFrame / pDC->pesp->getAnmCycleY()) & 1; // whether we're on an even or odd loop
curFrame = ptcl->mCurFrame; // fakematch; probably an inline function (getAge?)
f32 frame = (f32)((s32)curFrame % pDC->pesp->getAnmCycleY()) / pDC->pesp->getAnmCycleY();
f32 odd = (ptcl->getAge() / pDC->pesp->getAnmCycleY()) & 1; // whether we're on an even or odd loop
f32 frame = (f32)(ptcl->getAge() % pDC->pesp->getAnmCycleY()) / pDC->pesp->getAnmCycleY();
JPADrawContext::pcb->mScaleAnmTiming = odd + (frame - odd * 2.0f * frame);
}
+10 -12
View File
@@ -285,21 +285,20 @@ void JPABaseEmitter::calcParticle() {
JSULink<JPABaseParticle> * next = link->getNext();
JPABaseParticle * ptcl = (JPABaseParticle *) link->getObjectPtr();
ptcl->incFrame();
if (!(ptcl->mStatus & 0x80)) {
if (!ptcl->checkStatus(0x80)) {
ptcl->calcVelocity();
if (ptcl->mpCallBack2 != NULL)
ptcl->mpCallBack2->execute(this, ptcl);
if (!(ptcl->mStatus & 0x02)) {
ptcl->calcCB(this);
if (!ptcl->checkStatus(0x02)) {
mDraw.calcParticle(ptcl);
if (getEmitterDataBlockInfoPtr()->getSweepShape() != NULL && ptcl->checkCreateChild())
createChildren(ptcl);
ptcl->calcPosition();
}
} else {
ptcl->mStatus |= 0x02;
ptcl->setStatus(0x02);
}
if (ptcl->mStatus & 0x02)
if (ptcl->checkStatus(0x02))
deleteParticle(ptcl, &mActiveParticles);
link = next;
@@ -312,20 +311,19 @@ void JPABaseEmitter::calcChild() {
JSULink<JPABaseParticle> * next = link->getNext();
JPABaseParticle * ptcl = (JPABaseParticle *) link->getObjectPtr();
ptcl->incFrame();
if (!(ptcl->mStatus & 0x80)) {
if (!ptcl->checkStatus(0x80)) {
if ((s32)ptcl->mCurFrame != 0)
ptcl->calcVelocity();
if (ptcl->mpCallBack2 != NULL)
ptcl->mpCallBack2->execute(this, ptcl);
if (!(ptcl->mStatus & 0x02)) {
ptcl->calcCB(this);
if (!ptcl->checkStatus(0x02)) {
mDraw.calcChild(ptcl);
ptcl->calcPosition();
}
} else {
ptcl->mStatus |= 0x02;
ptcl->setStatus(0x02);
}
if (ptcl->mStatus & 0x02)
if (ptcl->checkStatus(0x02))
deleteParticle(ptcl, &mChildParticles);
link = next;
+2 -3
View File
@@ -288,8 +288,7 @@ void JPAConvectionField::calc(JPAFieldData* data, JPABaseParticle* ptcl) {
/* 8025B3CC-8025B50C .text calc__14JPARandomFieldFP12JPAFieldDataP15JPABaseParticle */
void JPARandomField::calc(JPAFieldData* data, JPABaseParticle* ptcl) {
/* Nonmatching */
s32 frame = ptcl->mCurFrame;
s32 frame = ptcl->getAge();
if (frame != 0) {
if (data->mCycle == 0)
return;
@@ -316,7 +315,7 @@ void JPADragField::init(JPAFieldData* data, JPABaseParticle* ptcl) {
/* 8025B584-8025B5F4 .text calc__12JPADragFieldFP12JPAFieldDataP15JPABaseParticle */
void JPADragField::calc(JPAFieldData* data, JPABaseParticle* ptcl) {
if (ptcl->checkStatus(0x04)) {
if (ptcl->checkStatus(JPAPtlcStts_Child)) {
ptcl->mDrag *= ptcl->mFieldDrag;
} else {
f32 affect = JPABaseField::calcFadeAffect(data, ptcl->mCurNormTime);
+9 -9
View File
@@ -18,13 +18,13 @@ void JPABaseParticle::initParticle() {
JGeometry::TVec3<f32> velDir;
JGeometry::TVec3<f32> velRndm;
mStatus = 0x01;
initStatus(JPAPtclStts_FirstFrame);
mFieldAccel.zero();
mFieldDrag = 1.0f;
mDrag = 1.0f;
MTXMultVec(emtrInfo.mEmitterGlobalSR, emtrInfo.mVolumePos, mLocalPosition);
if ((emtr->mDataFlag & 0x08) != 0)
mStatus |= 0x20;
setStatus(0x20);
mGlobalPosition.set(emtrInfo.mEmitterGlobalCenter);
@@ -88,7 +88,7 @@ void JPABaseParticle::initParticle() {
mGlobalPosition.z + mLocalPosition.z * emtrInfo.mPublicScale.z
);
mpCallBack2 = emtr->mpParticleCallBack;
setCallBackPtr(emtr->mpParticleCallBack);
emtr->mFieldManager.init(this);
field_0xd0 = 0;
}
@@ -100,10 +100,10 @@ void JPABaseParticle::initChild(JPABaseParticle* parent) {
JPABaseEmitter * emtr = emtrInfo.mpCurEmitter;
JPASweepShape * sweep = emtr->mpDataLinkInfo->getSweepShape();
mStatus = 0x04 | 0x01;
initStatus(JPAPtclStts_FirstFrame | JPAPtlcStts_Child);
if (!sweep->isEnableField()) {
mStatus |= 0x40;
setStatus(0x40);
mFieldDrag = 1.0f;
mDrag = 1.0f;
} else {
@@ -137,7 +137,7 @@ void JPABaseParticle::initChild(JPABaseParticle* parent) {
mVelocity = vel;
if (emtr->checkEmDataFlag(0x10))
mStatus |= 0x20;
setStatus(0x20);
mGlobalPosition.set(parent->mGlobalPosition);
mLocalPosition.set(parent->mLocalPosition);
@@ -151,7 +151,7 @@ void JPABaseParticle::initChild(JPABaseParticle* parent) {
mLocalPosition.add(unit);
}
mpCallBack2 = emtr->mpParticleCallBack;
setCallBackPtr(emtr->mpParticleCallBack);
field_0xd0 = parent->field_0xd0;
}
@@ -161,11 +161,11 @@ void JPABaseParticle::incFrame() {
if (mCurFrame < 0.0f)
mCurFrame = 0.0f;
mStatus &= ~0x01;
clearStatus(JPAPtclStts_FirstFrame);
if (mCurFrame >= mLifeTime) {
mCurNormTime = 1.0f;
mStatus |= 0x02;
setStatus(0x02); // setDeleteParticleFlag
} else {
mCurNormTime = mCurFrame / mLifeTime;
}
+21 -26
View File
@@ -2,11 +2,11 @@
* d_a_player_particle.inc
*
* Code relating to various particle effects.
*
* This file is not a standalone translation unit and is instead directly
*
* This file is not a standalone translation unit and is instead directly
* included into d_a_player_main.cpp.
*
* The original name of this file is not known, but a best guess was taken
*
* The original name of this file is not known, but a best guess was taken
* based on the original names of the functions it contains.
*/
@@ -47,12 +47,12 @@ void daPy_swimTailEcallBack_c::remove() {
/* 8012910C-80129310 .text execute__24daPy_swimTailEcallBack_cFP14JPABaseEmitter */
void daPy_swimTailEcallBack_c::execute(JPABaseEmitter* emitter) {
static JGeometry::TVec3<f32> right_dir(-1.0f, 0.0f, 0.0f);
GXColor ambColor;
GXColor difColor;
dKy_get_seacolor(&ambColor, &difColor);
emitter->setGlobalPrmColor(ambColor.r, ambColor.g, ambColor.b);
if (field_0x04) {
s16 sp8 = emitter->getGlobalAlpha();
cLib_chaseS(&sp8, 0, 0x14);
@@ -64,7 +64,7 @@ void daPy_swimTailEcallBack_c::execute(JPABaseEmitter* emitter) {
return;
}
}
if (field_0x20 != NULL) {
emitter->setGlobalTranslation(field_0x14.x, field_0x14.y, field_0x14.z);
JGeometry::TVec3<s16> rot(0, 0, 0);
@@ -77,22 +77,22 @@ void daPy_swimTailEcallBack_c::execute(JPABaseEmitter* emitter) {
emitter->setGlobalTranslation(sp20);
cLib_chaseF(&field_0x08, 0.0f, 0.08f);
}
emitter->setDirectionalSpeed(1.0f + 12.0f * field_0x08);
if (field_0x05) {
emitter->setDirection(right_dir);
}
for (JSULink<JPABaseParticle>* link = emitter->mActiveParticles.getFirst(); link != NULL;) {
JSULink<JPABaseParticle>* nextLink = link->getNext();
JPABaseParticle* particle = link->getObject();
JGeometry::TVec3<f32> sp14;
particle->getGlobalPosition(sp14);
getMaxWaterY(&sp14);
particle->setOffsetPosition(sp14);
link = nextLink;
}
}
@@ -128,7 +128,7 @@ void daPy_swBlur_c::copySwBlur(MtxP, int) {
void daPy_swBlur_c::draw() {
j3dSys.reinitGX();
GXSetNumIndStages(0);
static GXTexObj texObj;
u16 texWidth = 16;
u16 texHeight = 4;
@@ -136,14 +136,14 @@ void daPy_swBlur_c::draw() {
GXInitTexObj(&texObj, (u8*)mpTex + mpTex->imageOffset, texWidth, texHeight, texFormat, GX_CLAMP, GX_CLAMP, GX_FALSE);
GXInitTexObjLOD(&texObj, GX_LINEAR, GX_LINEAR, 0.0f, 0.0f, 0.0f, GX_FALSE, GX_FALSE, GX_ANISO_1);
GXLoadTexObj(&texObj, GX_TEXMAP0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_CLR_RGBA, GX_F32, 0);
GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_TEX0, GX_CLR_RGBA, GX_S16, 8);
GXClearVtxDesc();
GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT);
GXSetNumChans(0);
if (mBlurColorType == 0) {
// Normal color.
static GXColor n_color = {0xFF, 0xFF, 0xFF, 0x96};
@@ -157,7 +157,7 @@ void daPy_swBlur_c::draw() {
static GXColor g_color = {0x5A, 0xFF, 0x5A, 0x96};
GXSetTevColor(GX_TEVREG0, g_color);
}
GXSetNumTexGens(1);
GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY);
GXSetNumTevStages(1);
@@ -172,7 +172,7 @@ void daPy_swBlur_c::draw() {
GXSetCullMode(GX_CULL_NONE);
GXSetZMode(GX_TRUE, GX_LEQUAL, GX_FALSE);
GXSetAlphaCompare(GX_GREATER, 0, GX_AOP_OR, GX_GREATER, 0);
int r30 = 0xFF / ((field_0x014 >> 1) + 1);
s16 r29 = r30;
s16 r28 = 0x00;
@@ -232,13 +232,8 @@ daPy_waterDropPcallBack_c daPy_waterDropEcallBack_c::m_pcallback;
/* 80129FD4-8012A040 .text execute__25daPy_waterDropEcallBack_cFP14JPABaseEmitter */
void daPy_waterDropEcallBack_c::execute(JPABaseEmitter* emitter) {
daPy_followEcallBack_c::execute(emitter);
bool shouldEnd = false;
if (emitter->checkStatus(0x08) && emitter->getParticleNumber() == 0) {
shouldEnd = true;
}
if (shouldEnd) {
if (emitter->isEnableDeleteEmitter())
end();
}
}
/* 8012A040-8012A058 .text setup__25daPy_waterDropEcallBack_cFP14JPABaseEmitterPC4cXyzPC5csXyzSc */
@@ -365,10 +360,10 @@ void daPy_lk_c::setDamageFlameEmitter() {
0x0007, // LarmB_jnt
0x000B, // RarmB_jnt
};
if (!daPy_dmEcallBack_c::checkFlame()) {
endDamageEmitter();
const u16* jointNoP = flame_joint;
daPy_dmEcallBack_c* dmECB = mDmEcallBack;
for (int i = 0; i < (s32)ARRAY_SIZE(mDmEcallBack); i++, jointNoP++, dmECB++) {
@@ -383,7 +378,7 @@ void daPy_lk_c::setDamageFlameEmitter() {
}
}
}
daPy_dmEcallBack_c::setFlame(100);
}
+1 -1
View File
@@ -431,7 +431,7 @@ void dPa_simpleEcallBack::executeAfter(JPABaseEmitter* param_1) {
particle->setOffsetPosition(simpleData->mPos.x, simpleData->mPos.y, simpleData->mPos.z);
if (simpleData->mbAffectedByWind) {
static dPa_windPcallBack l_windPcallBack;
particle->mpCallBack2 = &l_windPcallBack;
particle->setCallBackPtr(&l_windPcallBack);
}
}
}