mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-07-13 05:49:21 -04:00
6be51c09c5
* launch.json cwd * bodge to load gci for testing * stub card stat * gameplay bodges * viewport, ub fixes * add release with debug info cmake variant * be fixes, sound stub * viewport h * d_msg_flow BE * be fopAcM_createItemFromEnemyID * update launch configuration to use iso * more audio stubs * Attempt to set viewport and get messages for brightness check * skip opening scene again, fixed JMessage::TResourceContainer::TCResource::Do_destroy * add guards for viewport changes * moar endian swapping to get Link sitting in PROC_OPENING_SCENE and for dialogues * BE d_msg_class i_data * stub bgm start * fix div by 0 error (for now) * TEMP_BROKEN in d_menu_ring * REQUIRES_GX_LINES * properly stub renderingAmap::draw with REQUIRES_GX_LINES * better stubbing outside of stubs * fix event data getting swapped multiple times * evil draw vp fix * Stub log imgui This redirects all spammy logs to an imgui window that is cleared per frame. This fixes the serious performance dip of the logging, and makes the regular log readable. * Oops move those optimization changes I accidentally committed behind a flag DUSK_SELECTED_OPT * gx_line macro in map * fix audio stubbing * switch to CARD API aurora impl * remove kabufuda from link libs * refactor imgui stuff and add input viewer * merge stub log with refactor * accidentally committed a metaforce header shh * basic map loader * ImGuiConsole: Add missing <thread> include * you may now play as luigi (you may now load stages with bridges) * bloom fix * bloom leak fix * cloud shadow fix * add soft reset button to imgui menu * if it broke dont not fix it * i swear i committed this * BE swap indMtx in JPAResource::setPTev * wnark ct fix * frsqrte implementation from kinoko * Fix Clang compile error in JAISeq::prepare_getSeqData_ * Add endian conversions to dMsgFlow_c::getInitNodeIndex This fixes a freeze when Fado tries to stop you from leaving the starting area. * Add RAII GXTexObj wrapper; fix almost all leaks * Update aurora for indirect texturing * Update aurora for CARD fix * Fix Clang build * More d_msg_flow endian fixes Fixes softlock when trying to talk to Fado and possibly other NPCs. * no frame limiter * get pause menu working * proper frame limiting * particle pointer size fix * improve map loader a bit --------- Co-authored-by: Jasper St. Pierre <jstpierre@mecheye.net> Co-authored-by: TakaRikka <takarikka@outlook.com> Co-authored-by: CraftyBoss <talibabdulmaalik@gmail.com> Co-authored-by: Luke Street <luke@street.dev> Co-authored-by: Lurs <l_werdes@gmx.de> Co-authored-by: PJB3005 <pieterjan.briers+git@gmail.com> Co-authored-by: tgsm <doodrabbit@hotmail.com> Co-authored-by: Max Roncace <me@caseif.net> Co-authored-by: Phillip Stephens <antidote.crk@gmail.com>
283 lines
11 KiB
C++
283 lines
11 KiB
C++
#ifndef JPAEMITTER_H
|
|
#define JPAEMITTER_H
|
|
|
|
#include <gx.h>
|
|
#include <stdint.h>
|
|
#include "JSystem/JParticle/JPAResource.h"
|
|
#include "JSystem/JParticle/JPAList.h"
|
|
#include "JSystem/JParticle/JPARandom.h"
|
|
#include "JSystem/JParticle/JPAMath.h"
|
|
#include "JSystem/JParticle/JPADynamicsBlock.h"
|
|
#include "JSystem/JSupport/JSUList.h"
|
|
|
|
class JPAResourceManager;
|
|
class JPABaseEmitter;
|
|
class JPAEmitterManager;
|
|
class JPAParticleCallBack;
|
|
|
|
/**
|
|
* @ingroup jsystem-jparticle
|
|
*
|
|
*/
|
|
struct JPAEmitterWorkData {
|
|
struct JPAVolumeCalcData {
|
|
/* 0x00 */ JGeometry::TVec3<f32> mVolumePos;
|
|
/* 0x0C */ JGeometry::TVec3<f32> mVelOmni;
|
|
/* 0x18 */ JGeometry::TVec3<f32> mVelAxis;
|
|
};
|
|
|
|
JPAEmitterWorkData() : mRndm(0) {}
|
|
|
|
/* 0x00 */ JPABaseEmitter* mpEmtr;
|
|
/* 0x04 */ JPAResource* mpRes;
|
|
/* 0x08 */ JPAResourceManager* mpResMgr;
|
|
/* 0x0C */ JPARandom mRndm;
|
|
/* 0x10 */ JPAVolumeCalcData mVolumeCalcData;
|
|
/* 0x34 */ f32 mVolumeSize;
|
|
/* 0x38 */ f32 mVolumeMinRad;
|
|
/* 0x3C */ f32 mVolumeSweep;
|
|
/* 0x40 */ s32 mEmitCount;
|
|
/* 0x44 */ s32 mVolumeEmitIdx;
|
|
/* 0x48 */ Mtx mDirectionMtx;
|
|
/* 0x78 */ Mtx mRotationMtx;
|
|
/* 0xA8 */ Mtx mGlobalRot;
|
|
/* 0xD8 */ Mtx mGlobalSR;
|
|
/* 0x108 */ JGeometry::TVec3<f32> mEmitterPos;
|
|
/* 0x114 */ JGeometry::TVec3<f32> mGlobalScl;
|
|
/* 0x120 */ JGeometry::TVec3<f32> mGlobalEmtrDir;
|
|
/* 0x12C */ JGeometry::TVec3<f32> mPublicScale;
|
|
/* 0x138 */ JGeometry::TVec3<f32> mGlobalPos;
|
|
/* 0x144 */ JGeometry::TVec2<f32> mGlobalPtclScl;
|
|
/* 0x14C */ JGeometry::TVec2<f32> mPivot;
|
|
/* 0x154 */ Mtx mYBBCamMtx;
|
|
/* 0x184 */ Mtx mPosCamMtx;
|
|
/* 0x1B4 */ Mtx mPrjMtx;
|
|
/* 0x1E4 */ JPAList<JPABaseParticle>* mpAlivePtcl;
|
|
/* 0x1E8 */ JPANode<JPABaseParticle>* mpCurNode;
|
|
/* 0x1EC */ s32 mVolumeAngleNum;
|
|
/* 0x1F0 */ s32 mVolumeAngleMax;
|
|
/* 0x1F4 */ s32 mVolumeX;
|
|
/* 0x1F8 */ s32 mDivNumber;
|
|
/* 0x1FC */ f32 mScaleAnm;
|
|
/* 0x200 */ u32 mDirType;
|
|
/* 0x204 */ u32 mRotType;
|
|
/* 0x208 */ u32 mPlaneType;
|
|
/* 0x20C */ u32 mDLType;
|
|
/* 0x210 */ u32 mPrjType;
|
|
/* 0x214 */ s16 mClrKeyFrame;
|
|
/* 0x216 */ u8 mDrawCount;
|
|
};
|
|
|
|
/**
|
|
* @ingroup jsystem-jparticle
|
|
*
|
|
*/
|
|
class JPAEmitterCallBack {
|
|
public:
|
|
virtual ~JPAEmitterCallBack() = 0;
|
|
virtual void execute(JPABaseEmitter*) {}
|
|
virtual void executeAfter(JPABaseEmitter*) {}
|
|
virtual void draw(JPABaseEmitter*) {}
|
|
virtual void drawAfter(JPABaseEmitter*) {}
|
|
};
|
|
|
|
enum {
|
|
JPAEmtrStts_StopEmit = 0x01,
|
|
JPAEmtrStts_StopCalc = 0x02,
|
|
JPAEmtrStts_StopDraw = 0x04,
|
|
JPAEmtrStts_EnableDeleteEmitter = 0x08,
|
|
JPAEmtrStts_FirstEmit = 0x10,
|
|
JPAEmtrStts_RateStepEmit = 0x20,
|
|
JPAEmtrStts_Immortal = 0x40,
|
|
JPAEmtrStts_Delete = 0x100,
|
|
};
|
|
|
|
/**
|
|
* @ingroup jsystem-jparticle
|
|
*
|
|
*/
|
|
class JPABaseEmitter {
|
|
public:
|
|
~JPABaseEmitter() {}
|
|
JPABaseEmitter() : mLink(this), mRndm(0) {}
|
|
void init(JPAEmitterManager*, JPAResource*);
|
|
bool processTillStartFrame();
|
|
bool processTermination();
|
|
void calcEmitterGlobalPosition(JGeometry::TVec3<f32>*) const;
|
|
void deleteAllParticle();
|
|
JPABaseParticle* createChild(JPABaseParticle*);
|
|
JPABaseParticle* createParticle();
|
|
u32 getCurrentCreateNumber() const;
|
|
u8 getDrawCount() const;
|
|
bool loadTexture(u8, GXTexMapID);
|
|
|
|
void initStatus(u32 status) { mStatus = status; }
|
|
void setStatus(u32 status) { mStatus |= status; }
|
|
void clearStatus(u32 status) { mStatus &= ~status; }
|
|
u32 checkStatus(u32 status) const { return (mStatus & status); }
|
|
u32 checkFlag(u32 flag) const { return pRes->getDyn()->getFlag() & flag; }
|
|
u8 getResourceManagerID() const { return mResMgrID; }
|
|
u8 getGroupID() const { return mGroupID; }
|
|
u8 getDrawTimes() const { return mDrawTimes; }
|
|
f32 getRate() const { return mRate; }
|
|
void setRate(f32 rate) { mRate = rate; }
|
|
void setDirectionalSpeed(f32 i_speed) { mDirSpeed = i_speed; }
|
|
void setRandomDirectionSpeed(f32 i_speed) { mRndmDirSpeed = i_speed; }
|
|
void setEmitterCallBackPtr(JPAEmitterCallBack* ptr) { mpEmtrCallBack = ptr; }
|
|
void setGlobalRTMatrix(const Mtx m) { JPASetRMtxTVecfromMtx(m, mGlobalRot, &mGlobalTrs); }
|
|
void setGlobalSRTMatrix(const Mtx m) {
|
|
JPASetRMtxSTVecfromMtx(m, mGlobalRot, &mGlobalScl, &mGlobalTrs);
|
|
mGlobalPScl.set(mGlobalScl.x, mGlobalScl.y);
|
|
}
|
|
void setGlobalTranslation(f32 x, f32 y, f32 z) { mGlobalTrs.set(x, y, z); }
|
|
void setGlobalTranslation(const JGeometry::TVec3<f32>& trs) { mGlobalTrs.set(trs); }
|
|
void getLocalTranslation(JGeometry::TVec3<f32>& vec) { vec.set(mLocalTrs); }
|
|
void getLocalTranslation(JGeometry::TVec3<f32>* vec) const { vec->set(mLocalTrs); }
|
|
void setGlobalRotation(const JGeometry::TVec3<s16>& rot) {
|
|
JPAGetXYZRotateMtx(rot.x, rot.y, rot.z, mGlobalRot);
|
|
}
|
|
void getGlobalTranslation(JGeometry::TVec3<f32>* out) const { out->set(mGlobalTrs); }
|
|
void setGlobalDynamicsScale(const JGeometry::TVec3<f32>& i_scale) { mGlobalScl.set(i_scale); }
|
|
void getGlobalDynamicsScale(JGeometry::TVec3<f32>* i_scale) const { i_scale->set(mGlobalScl); }
|
|
void setGlobalAlpha(u8 alpha) { mGlobalPrmClr.a = alpha; }
|
|
u8 getGlobalAlpha() const { return mGlobalPrmClr.a; }
|
|
void getGlobalPrmColor(GXColor& color) { color = mGlobalPrmClr; }
|
|
void getGlobalPrmColor(GXColor* color) const { *color = mGlobalPrmClr; }
|
|
void setGlobalPrmColor(u8 r, u8 g, u8 b) { mGlobalPrmClr.r = r; mGlobalPrmClr.g = g; mGlobalPrmClr.b = b; }
|
|
void setGlobalEnvColor(u8 r, u8 g, u8 b) { mGlobalEnvClr.r = r; mGlobalEnvClr.g = g; mGlobalEnvClr.b = b; }
|
|
void setVolumeSize(u16 size) { mVolumeSize = size; }
|
|
void setLifeTime(s16 lifetime) { mLifeTime = lifetime; }
|
|
void setAwayFromCenterSpeed(f32 i_speed) { mAwayFromCenterSpeed = i_speed; }
|
|
void setAwayFromAxisSpeed(f32 i_speed) { mAwayFromAxisSpeed = i_speed; }
|
|
void setSpread(f32 i_spread) { mSpread = i_spread; }
|
|
void setLocalTranslation(const JGeometry::TVec3<f32>& i_trans) { mLocalTrs.set(i_trans); }
|
|
void setLocalRotation(const JGeometry::TVec3<s16>& i_rot) {
|
|
mLocalRot.set(i_rot.x * (360.0f / 0xffff), i_rot.y * (360.0f / 0xffff),
|
|
i_rot.z * (360.0f / 0xffff));
|
|
}
|
|
void setRateStep(u8 i_step) { mRateStep = i_step; }
|
|
|
|
void setGlobalParticleHeightScale(f32 height) {
|
|
mGlobalPScl.y = height;
|
|
}
|
|
void setGlobalParticleScale(const JGeometry::TVec3<f32>& scale) {
|
|
mGlobalPScl.set((f32)scale.x, (f32)scale.y);
|
|
}
|
|
void setGlobalParticleScale(f32 scaleX, f32 scaleY) {
|
|
mGlobalPScl.set(scaleX, scaleY);
|
|
}
|
|
void getGlobalParticleScale(JGeometry::TVec3<f32>& scale) const {
|
|
scale.set(mGlobalPScl.x, mGlobalPScl.y, 1.0f);
|
|
}
|
|
void getGlobalParticleScale(JGeometry::TVec3<f32>* scale) const {
|
|
scale->set(mGlobalPScl.x, mGlobalPScl.y, 1.0f);
|
|
}
|
|
void setGlobalScale(const JGeometry::TVec3<f32>& scale) {
|
|
mGlobalScl.set(scale);
|
|
mGlobalPScl.set(scale.x ,scale.y);
|
|
}
|
|
void setDirection(const JGeometry::TVec3<f32>& direction) {
|
|
mLocalDir.set(direction);
|
|
}
|
|
|
|
void setLocalScale(const JGeometry::TVec3<f32>& scale) {
|
|
mLocalScl.set(scale);
|
|
}
|
|
|
|
f32 get_r_f() { return mRndm.get_rndm_f(); }
|
|
f32 get_r_zp() { return mRndm.get_rndm_zp(); }
|
|
f32 get_r_zh() { return mRndm.get_rndm_zh(); }
|
|
s16 get_r_ss() { return mRndm.get_rndm_ss(); }
|
|
|
|
void stopCreateParticle() { setStatus(JPAEmtrStts_StopEmit); }
|
|
void playCreateParticle() { clearStatus(JPAEmtrStts_StopEmit); }
|
|
void becomeImmortalEmitter() { setStatus(JPAEmtrStts_Immortal); }
|
|
void becomeContinuousParticle() { mMaxFrame = 0; }
|
|
void becomeDeleteEmitter() { setStatus(JPAEmtrStts_Delete); }
|
|
void becomeInvalidEmitter() {
|
|
stopCreateParticle();
|
|
mMaxFrame = 1;
|
|
}
|
|
|
|
void quitImmortalEmitter() { clearStatus(JPAEmtrStts_Immortal); }
|
|
void stopCalcEmitter() { setStatus(JPAEmtrStts_StopCalc); }
|
|
void playCalcEmitter() { clearStatus(JPAEmtrStts_StopCalc); }
|
|
void stopDrawParticle() { setStatus(JPAEmtrStts_StopDraw); }
|
|
void playDrawParticle() { clearStatus(JPAEmtrStts_StopDraw); }
|
|
|
|
uintptr_t getUserWork() const { return mpUserWork; }
|
|
void setUserWork(uintptr_t userWork) { mpUserWork = userWork; }
|
|
u32 getParticleNumber() const {
|
|
return mAlivePtclBase.getNum() + mAlivePtclChld.getNum();
|
|
}
|
|
bool isEnableDeleteEmitter() const {
|
|
return checkStatus(JPAEmtrStts_EnableDeleteEmitter) && getParticleNumber() == 0;
|
|
}
|
|
void setDrawTimes(u8 drawTimes) { mDrawTimes = drawTimes; }
|
|
void setParticleCallBackPtr(JPAParticleCallBack* cb) { mpPtclCallBack = cb; }
|
|
JPAParticleCallBack* getParticleCallBackPtr() const { return mpPtclCallBack; }
|
|
JPAEmitterCallBack* getEmitterCallBackPtr() const { return mpEmtrCallBack; }
|
|
u32 getAge() const { return mTick; }
|
|
|
|
void setVolumeMiniRadius(f32 param_1) {
|
|
mVolumeMinRad = param_1;
|
|
}
|
|
|
|
void setMaxFrame(s32 maxFrame) {
|
|
mMaxFrame = maxFrame;
|
|
}
|
|
|
|
public:
|
|
/* 0x00 */ JGeometry::TVec3<f32> mLocalScl;
|
|
/* 0x0C */ JGeometry::TVec3<f32> mLocalTrs;
|
|
/* 0x18 */ JGeometry::TVec3<f32> mLocalDir;
|
|
/* 0x24 */ s32 mMaxFrame;
|
|
/* 0x28 */ f32 mRate;
|
|
/* 0x2C */ f32 mVolumeSweep;
|
|
/* 0x30 */ f32 mVolumeMinRad;
|
|
/* 0x34 */ f32 mAwayFromCenterSpeed;
|
|
/* 0x38 */ f32 mAwayFromAxisSpeed;
|
|
/* 0x3C */ f32 mDirSpeed;
|
|
/* 0x40 */ f32 mSpread;
|
|
/* 0x44 */ f32 mRndmDirSpeed;
|
|
/* 0x48 */ f32 mAirResist;
|
|
/* 0x4C */ JGeometry::TVec3<s16> mLocalRot;
|
|
/* 0x52 */ s16 mLifeTime;
|
|
/* 0x54 */ u16 mVolumeSize;
|
|
/* 0x56 */ u8 mRateStep;
|
|
/* 0x58 */ JSULink<JPABaseEmitter> mLink;
|
|
/* 0x68 */ Mtx mGlobalRot;
|
|
/* 0x98 */ JGeometry::TVec3<f32> mGlobalScl;
|
|
/* 0xA4 */ JGeometry::TVec3<f32> mGlobalTrs;
|
|
/* 0xB0 */ JGeometry::TVec2<f32> mGlobalPScl;
|
|
/* 0xB8 */ GXColor mGlobalPrmClr;
|
|
/* 0xBC */ GXColor mGlobalEnvClr;
|
|
/* 0xC0 */ uintptr_t mpUserWork;
|
|
/* 0xC4 */ JPARandom mRndm;
|
|
/* 0xC8 */ JPAList<JPABaseParticle> mAlivePtclBase;
|
|
/* 0xD4 */ JPAList<JPABaseParticle> mAlivePtclChld;
|
|
/* 0xE0 */ JPAList<JPABaseParticle>* mpPtclPool;
|
|
/* 0xE4 */ JPAEmitterManager* mpEmtrMgr;
|
|
/* 0xE8 */ JPAResource* pRes;
|
|
/* 0xEC */ JPAEmitterCallBack* mpEmtrCallBack;
|
|
/* 0xF0 */ JPAParticleCallBack* mpPtclCallBack;
|
|
/* 0xF4 */ u32 mStatus;
|
|
/* 0xF8 */ f32 mEmitCount;
|
|
/* 0xFC */ f32 mScaleOut;
|
|
/* 0x100 */ u32 mTick;
|
|
/* 0x104 */ s16 mWaitTime;
|
|
/* 0x106 */ s16 mRateStepTimer;
|
|
/* 0x108 */ GXColor mPrmClr;
|
|
/* 0x10C */ GXColor mEnvClr;
|
|
/* 0x110 */ u8 mDrawTimes;
|
|
/* 0x111 */ u8 mTexAnmIdx;
|
|
/* 0x112 */ u8 mGroupID;
|
|
/* 0x113 */ u8 mResMgrID;
|
|
};
|
|
|
|
enum {
|
|
JPAPtclStts_Invisible = 0x08,
|
|
};
|
|
|
|
#endif /* JPAEMITTER_H */
|