diff --git a/include/JSystem/JParticle/JPAEmitter.h b/include/JSystem/JParticle/JPAEmitter.h index a24581542..783879469 100644 --- a/include/JSystem/JParticle/JPAEmitter.h +++ b/include/JSystem/JParticle/JPAEmitter.h @@ -266,6 +266,8 @@ class JPABaseEmitter { stopCreateParticle(); } + bool isZDraw() { return mDraw.isZDraw(); } + void setEmitterCallBackPtr(JPACallBackBase* callback) { mpEmitterCallBack = callback; } @@ -274,6 +276,8 @@ class JPABaseEmitter { } void setParticleList(JSUList* list) { mpPtclVacList = list; } void setFieldList(JSUList* list) { mFieldManager.mVacList = list; } + JSUList* getParticleList() { return &mActiveParticles; } + JSUList* getChildParticleList() { return &mChildParticles; } JSULink* getLinkBufferPtr() { return &mLink; } void initDrawMgr(JPATextureResource* texRes) { mDraw.initialize(this, texRes); } void draw(MtxP cameraMtxP) { mDraw.draw(cameraMtxP); } @@ -294,15 +298,12 @@ class JPABaseEmitter { void getBaseEnvColor(GXColor&) {} void getBasePrmColor(GXColor&) {} void getCamMtxPtr() {} - JSUList* getChildParticleList() { return &mChildParticles; } void getCurrentCreateNumber() const {} void getFrame() {} void getGlobalParticleScale(JGeometry::TVec3&) const {} - JSUList* getParticleList() { return &mActiveParticles; } void getgReRDirection(JGeometry::TVec3&) {} void isChildDraw() {} void isContinuousParticle() {} - bool isZDraw() { return mDraw.isZDraw(); } void loadTexture(u8, GXTexMapID) {} void setEmitterRotation(const JGeometry::TVec3&) {} void setGlobalParticleHeightScale(f32) {} diff --git a/include/JSystem/JParticle/JPAParticle.h b/include/JSystem/JParticle/JPAParticle.h index 697c2b440..709d0a558 100644 --- a/include/JSystem/JParticle/JPAParticle.h +++ b/include/JSystem/JParticle/JPAParticle.h @@ -22,6 +22,8 @@ template class JPACallBackBase2; enum JPAParticleStatus { + JPAPtclStts_FirstFrame = 0x01, + JPAPtlcStts_Child = 0x04, JPAPtclStts_Invisible = 0x08, }; @@ -40,15 +42,18 @@ class JPABaseParticle { void setOffsetPosition(f32 x, f32 y, f32 z) { mGlobalPosition.set(x, y, z); } void setOffsetPosition(const JGeometry::TVec3& pos) { mGlobalPosition.set(pos); } void getGlobalPosition(JGeometry::TVec3& 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* 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 @@ class JPABaseParticle { void getOffsetPosition(JGeometry::TVec3&) const {} void getVelVec(JGeometry::TVec3&) const {} void getWidth() {} - void initStatus(u32) {} - void setCallBackPtr(JPACallBackBase2*) {} void setDeleteParticleFlag() {} - void setStatus(u32) {} public: /* 0x00 */ JSULink mLink; @@ -91,7 +93,7 @@ class JPABaseParticle { /* 0xBC */ GXColor mEnvColor; /* 0xC0 */ u16 mRotateAngle; /* 0xC2 */ s16 mRotateSpeed; - /* 0xC4 */ u8 field_0xC4[0xC6 - 0xC4]; + /* 0xC4 */ u16 field_0xC4; /* 0xC6 */ u16 mTexIdx; /* 0xC8 */ JPACallBackBase2* mpCallBack2; /* 0xCC */ u32 mStatus; diff --git a/src/JSystem/JParticle/JPADrawVisitor.cpp b/src/JSystem/JParticle/JPADrawVisitor.cpp index 64bb10543..eaaa6dd73 100644 --- a/src/JSystem/JParticle/JPADrawVisitor.cpp +++ b/src/JSystem/JParticle/JPADrawVisitor.cpp @@ -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); } diff --git a/src/JSystem/JParticle/JPAEmitter.cpp b/src/JSystem/JParticle/JPAEmitter.cpp index a1ca2903c..7fd804378 100644 --- a/src/JSystem/JParticle/JPAEmitter.cpp +++ b/src/JSystem/JParticle/JPAEmitter.cpp @@ -285,21 +285,20 @@ void JPABaseEmitter::calcParticle() { JSULink * 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 * 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; diff --git a/src/JSystem/JParticle/JPAField.cpp b/src/JSystem/JParticle/JPAField.cpp index 750d6fffc..8c19ef44c 100644 --- a/src/JSystem/JParticle/JPAField.cpp +++ b/src/JSystem/JParticle/JPAField.cpp @@ -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); diff --git a/src/JSystem/JParticle/JPAParticle.cpp b/src/JSystem/JParticle/JPAParticle.cpp index 352520723..4e227a63a 100644 --- a/src/JSystem/JParticle/JPAParticle.cpp +++ b/src/JSystem/JParticle/JPAParticle.cpp @@ -18,13 +18,13 @@ void JPABaseParticle::initParticle() { JGeometry::TVec3 velDir; JGeometry::TVec3 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; } diff --git a/src/d/actor/d_a_player_particle.inc b/src/d/actor/d_a_player_particle.inc index f158193e5..ac42d70cf 100644 --- a/src/d/actor/d_a_player_particle.inc +++ b/src/d/actor/d_a_player_particle.inc @@ -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 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 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* link = emitter->mActiveParticles.getFirst(); link != NULL;) { JSULink* nextLink = link->getNext(); JPABaseParticle* particle = link->getObject(); - + JGeometry::TVec3 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); } diff --git a/src/d/d_particle.cpp b/src/d/d_particle.cpp index 358159361..b93df24f6 100644 --- a/src/d/d_particle.cpp +++ b/src/d/d_particle.cpp @@ -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); } } }