resonance 1.0.1
Loading...
Searching...
No Matches
Rnd::PsParticleSys Class Reference

PlayStation 2 particle system, which submits its particles to the GS. More...

#include <psparticlesys.h>

Inheritance diagram for Rnd::PsParticleSys:
Collaboration diagram for Rnd::PsParticleSys:

Public Member Functions

 PsParticleSys (const HxStr &name)
 Construct an empty PlayStation 2 particle system.
virtual ~PsParticleSys ()
Public Member Functions inherited from Rnd::ParticleSys
 ParticleSys (const HxStr &name)
 Construct an empty system that owns its own particles.
virtual ~ParticleSys ()
virtual void DumpText (Dbg &sink)
 Write the system to the engine text sink.
virtual void Save (Stream &stream)
 Serialise the system.
virtual void Replace (Object *pFrom, Object *pTo)
 Replace one object reference with another.
virtual const HxStr & ClassName () const
 Return the registered class name, "ParticleSys".
virtual void Copy (const Object *pSource, unsigned nFlags)
 Copy another system over this one.
virtual void Load (Stream &stream)
 Load the system.
virtual void StartAnim ()
 Restart the emission and release every live particle.
void FreeAllParticles ()
 Release every live particle back to the pool of its owner.
Particle * AllocParticle ()
 Take one particle from the pool of the owner and push it onto the live list.
Particle * FreeParticle (Particle *pParticle)
 Unlink one live particle and push it onto the free list of the owner.
void RandomizeColorAndSize (Particle *pParticle)
 Draw a random spawn colour and size for one particle.
void SetMat (Mat *pMat)
 Point the system at a material, moving its reference registration from the old one.
void SetParticlesOwner (ParticleSys *pOwner)
 Draw the particles of another system, or of this one.
Particle * GetLiveParticles () const
 Report the head of the live list.
void SetForce (const Vector3 &force)
 Replace the force every particle accelerates by.
Vector3 & GetForce ()
 Report the force every particle accelerates by.
Public Member Functions inherited from Rnd::Animatable
 Animatable ()
 Construct an animatable with no children, no filters, and a zero frame.
virtual ~Animatable ()
 Drop this object's references on its children and delete its filters.
Animatable * Parent ()
 Report the animatable that animates this one.
void AddAnim (Animatable *pAnim)
 Append pAnim to mAnims.
void RemoveAnim (Animatable *pAnim)
 Erase pAnim from mAnims.
void SetFrame (float flFrame)
 Drive this object and its whole subtree to a frame.
float UnfilterFrame (float flValue)
 Map a value back through mFilters.
void AddFilter (Filter *pFilter)
 Append an already-built filter to mFilters.
void AddScaleOffset (float flScale, float flOffset)
 Append a new ScaleOffset stage to mFilters.
void AddMinMaxLoop (float flMin, float flMax, int nLoop)
 Append a new MinMaxLoop stage to mFilters.
void AddZeroOrder (float flLevel, float flMaxDelta)
 Append a new ZeroOrder stage to mFilters.
void AddFirstOrder (float flLevel, float flRatio)
 Append a new FirstOrder stage to mFilters.
void AddSecondOrder (float flLevel, float flSpring, float flDamper)
 Append a new SecondOrder stage to mFilters.
void RemoveFilter (int nIndex)
 Delete and erase the filter at one position in mFilters.
Filter * FilterAt (int nIndex)
 Return the filter at one position in mFilters.
void SetRate (float flRate)
 Change the multiplier of the ScaleOffset stage at the front of mFilters.
void SetOffset (float flOffset)
 Change the addend of the ScaleOffset stage at the front of mFilters.
void SetLoopRange (float flMin, float flMax)
 Change both ends of the MinMaxLoop stage at the back of mFilters.
virtual float FilteredFrameEnd ()
 Report the last frame this object's subtree animates to.
void RemoveAllAnims ()
 Drop this object's reference on every mAnims entry and then empty mAnims.
Public Member Functions inherited from Rnd::Object
 Object ()
 Construct an unnamed object.
 Object (const HxStr &name)
 Construct an object and register it under name.
virtual ~Object ()
 Erase the registry entry and release the name buffer.
void SetName (const HxStr &name)
 Re-register this object under a different name.
void AddRef (Object *pReferrer)
 Register pReferrer as a store of a pointer to this object.
void RemoveRef (Object *pReferrer)
 Drop one registration made by AddRef().
Public Member Functions inherited from Rnd::Transformable
 Transformable ()
 Construct a dirty transformable with identity transforms and no children.
virtual ~Transformable ()
 Drop this object's references on its children.
void AddTrans (Transformable *pTrans)
 Append pTrans to mTransList and mark it dirty.
void RemoveTrans (Transformable *pTrans)
 Erase pTrans from mTransList.
void RemoveAllTranses ()
 Drop this object's reference on every mTransList entry and empty the list.
Transformable * Parent ()
 Report the transformable that positions this one.
virtual void SetBillboard (int nBillboard)
 Set the billboard mode and mark the transform dirty.
virtual int UpdateWorldXfm (Transformable *pParent, int nForce)
 Compose mWorldXfm from mLocalXfm and the parent's world transform.
void SetOrigin (const float *pOrigin)
 Set the origin row and mark the transform dirty.
float * GetDrawXfm ()
 Build the transform this object draws with and return it.
Public Member Functions inherited from Rnd::Drawable
 Drawable ()
 Construct a visible drawable with no children.
virtual ~Drawable ()
 Drop this object's references on its children.
void Draw ()
 Draw this object followed by each of its children.
Drawable * Parent ()
 Report the drawable that draws this one.
void AddDraw (Drawable *pDraw, Drawable *pBefore)
 Insert pDraw into mDraws in front of pBefore.
void AddDraw (Drawable *pDraw)
 Insert pDraw at the front of mDraws.
void RemoveDraw (Drawable *pDraw)
 Erase pDraw from mDraws.
void RemoveAllDraws ()
 Empty mDraws, dropping this object's reference on every entry.
void MoveDraw (Drawable *pDraw, int nSteps)
 Move pDraw nSteps places later in mDraws, or earlier for a negative count.
virtual void SetShowing (int nShowing)
 Set whether this object draws at all.
void SetShowingRecursive (int nShowing)
 Set whether this object and every drawable beneath it in mDraws draw at all.
virtual void SetHighlight (int nHighlight)
 Set whether this object draws with its highlight treatment.
int GetHighlight () const
 Report the highlight flag.
int GetShowing () const
 Report the showing flag.
std::list< Drawable * > & GetDraws ()
 Report the child list.

Protected Member Functions

virtual int DrawShowing ()
 Draw the particles.
Protected Member Functions inherited from Rnd::ParticleSys
virtual void SetFrameSelf (float flFrame)
 Advance the emission to a frame.
void SetNumParticles (int nCount)
 Resize the particle owner's pool, the count the dump labels "numParticles:".
Protected Member Functions inherited from Rnd::Object
void ReleaseAllRefs ()
 Tell every referrer to drop its pointer to this object.
Protected Member Functions inherited from Rnd::Transformable
void AdoptXfmFrom (const Transformable &owner)
 Adopt the transform of an owner this object is being detached from.
void ReleaseTransRefs ()
 Drop this object's reference on every mTransList entry without emptying the list.
Protected Member Functions inherited from Rnd::Drawable
void ReleaseDrawsRefs ()
 Drop this object's reference on every mDraws entry without emptying the list.

Additional Inherited Members

Public Types inherited from Rnd::ParticleSys
enum  Type { kModePoint = 0 , kModeLine = 1 , kModeSprite = 2 }
 Primitive a system draws each particle as. More...
Public Types inherited from Rnd::Animatable
enum  FilterType {
  kFilterScaleOffset = 0 , kFilterMinMaxLoop = 1 , kFilterZeroOrder = 2 , kFilterFirstOrder = 3 ,
  kFilterSecondOrder = 4
}
 Value a filter reports from Filter::Type() and a .rnd file stores in front of its payload. More...
Public Types inherited from Rnd::Transformable
enum  Billboard {
  kBillboardNone = 0 , kBillboardX = 1 , kBillboardY = 2 , kBillboardZ = 4 ,
  kBillboardXZ = 8 , kBillboardXYZ = 16 , kBillboardSimpleXYZ = 32 , kBillboardLocalRotate = 64 ,
  kBillboardScaleX = 129 , kBillboardScaleY = 130 , kBillboardScaleZ = 132 , kBillboardScaleXZ = 136 ,
  kBillboardScaleXYZ = 144 , kBillboardScaleSimpleXYZ = 160
}
 Mode mBillboard selects, recovered from the name dumper at 0x004f26f0. More...
Static Public Member Functions inherited from Rnd::ParticleSys
static void * operator new (size_t nSize)
 Allocate a particle system under the tag "Rnd::ParticleSys".
static void operator delete (void *pBlock)
 Release a particle system block under the same tag.
Static Public Member Functions inherited from Rnd::Animatable
static Filter * NewFilter (int nType)
 Build one default-constructed filter for a type tag.
Static Public Member Functions inherited from Rnd::Drawable
static Drawable * Find (const HxStr &name)
 Resolve a registry key to a drawable.
Public Attributes inherited from Rnd::ParticleSys
std::vector< Particle > mParticles
float mEmitRateLow
float mEmitRateHigh
float mSizeLow
float mSizeHigh
Color mStartColorLow
Color mStartColorHigh
Color mEndColorLow
Color mEndColorHigh
Mat * mMat
Type mMode
int mReadZ
int mLineLength
Public Attributes inherited from Rnd::Animatable
float mFilteredFrame
 The frame SetFrame() last received, after the filter chain.
Public Attributes inherited from Rnd::Object
HxStr mName
int mInternal
Public Attributes inherited from Rnd::Transformable
float mLocalXfm [kXfmRowCount][kXfmRowFloatCount]
 Transform this object is positioned by, before the parent transform is applied.
float mWorldXfm [kXfmRowCount][kXfmRowFloatCount]
 Composed world transform.
int mDirty
 Set by every writer of a transform field and cleared once UpdateWorldXfm has recomposed.
Public Attributes inherited from Rnd::Drawable
int mShowing
Static Public Attributes inherited from Rnd::ParticleSys
static constexpr unsigned kCopyShareParticles = 0x400
 Copy() flag that shares the source's particles rather than copying its pool.
Protected Attributes inherited from Rnd::ParticleSys
ParticleSys * mParticlesOwner
Particle * mLiveParticles
Protected Attributes inherited from Rnd::Object
std::list< Object * > mRefs
Protected Attributes inherited from Rnd::Transformable
float mOrigin [kXfmRowFloatCount]
int mBillboard

Detailed Description

PlayStation 2 particle system, which submits its particles to the GS.

Its RTTI descriptor is at 0x008f1250. It has Rnd::ParticleSys as its one public base at offset 0 and no member. The factory allocates 0x220 bytes, the same as the base. The equal size shows the subclass does not add data.

The subclass overrides exactly two virtuals, the destructor in the Object subobject table at 0x0083a250 and DrawShowing() in the Drawable table at 0x0083a298. Every other slot of all four tables still addresses the Rnd::ParticleSys implementation. The constructor body is empty.

Three submission paths serve the three modes, and which one runs also depends on whether the device is on the vector unit path. With VU1 selected only a sprite system draws at all, through DrawSpritesDmaKicked(); the point and line modes submit nothing. Without it the particles are first packed into the shared draw buffer by PackParticleQuads(), two Rnd::DrawVert records per particle, and then one of three emitters runs.

All three emitters share the buffer Rnd::PsMesh uses, which is why g_aDrawVerts is declared shared rather than owned by the mesh path, and all three respect the material state Rnd::PsMat::Select() published. The sprite emitter reads g_nStageTextureBound to choose between a six-register and a three-register GIFtag, and its PRIM word takes TME from the same global and ABE from g_nAlphaBlendEnabled.

The overflow guard mirrors the mesh one exactly. A population above 1250 reports "DrawShowing particle buffer overflow... %d" and continues rather than clamping, which is faithful.

Constructor & Destructor Documentation

◆ PsParticleSys()

Rnd::PsParticleSys::PsParticleSys ( const HxStr & name)

Construct an empty PlayStation 2 particle system.

The body is empty. Rnd::NewPsParticleSys() is the only construction site.

Parameters
nameThe object name, passed to the Rnd::Object constructor.
Ghidra address:
NTSC-U/C: 0x005fcdf0
Ghidra address:
PAL: 0x0063db00

◆ ~PsParticleSys()

virtual Rnd::PsParticleSys::~PsParticleSys ( )
virtual
Ghidra address:
NTSC-U/C: 0x005ff878
Ghidra address:
PAL: 0x006405f0

Member Function Documentation

◆ DrawShowing()

virtual int Rnd::PsParticleSys::DrawShowing ( )
protectedvirtual

Draw the particles.

Advances the mesh draw counter, returns at once when no particle is live, programs ZBUF_1.ZMSK to suppress depth writes and TEST_1.ZTST from mReadZ, and selects the material. The vector unit path then submits sprites alone, repeating the whole submission once per material pass. The software path packs the particles first and dispatches on the mode.

Returns
Always non-zero, so the children always draw.
Ghidra address:
NTSC-U/C: 0x005fcb18
Ghidra address:
PAL: 0x0063d828

Reimplemented from Rnd::Drawable.


The documentation for this class was generated from the following file: