|
resonance 1.0.1
|
Emitter that spawns, integrates, and draws a population of particles. More...
#include <particlesys.h>


Public Types | |
| 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... | |
Public Member Functions | |
| 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. | |
Static Public Member Functions | |
| 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 | |
| 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 | |
| static constexpr unsigned | kCopyShareParticles = 0x400 |
| Copy() flag that shares the source's particles rather than copying its pool. | |
Protected Member Functions | |
| 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 | |
| virtual int | DrawShowing () |
| Draw this object alone. | |
| void | ReleaseDrawsRefs () |
| Drop this object's reference on every mDraws entry without emptying the list. | |
Protected Attributes | |
| 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 |
Emitter that spawns, integrates, and draws a population of particles.
Its RTTI descriptor is at 0x008ef650. It has three public non-virtual bases: Rnd::Animatable at +0x00, Rnd::Transformable at +0x20, and Rnd::Drawable at +0xd0. All three derive virtually from Rnd::Object. One shared Object subobject sits at +0x200 and the factory allocates 0x220 bytes.
Four vtables belong to the class, each identified by its own GetTypeInfo slot addressing 0x0052b2d8. The Object subobject table at 0x00827b60 adjusts by -0x200, the Drawable table at 0x00827af0 by -0xd0, the Transformable table at 0x00827b18 by -0x20, and the Animatable table at 0x00827b38 by zero.
The class overrides seven of the eight Object virtuals and two of the three Animatable ones. It overrides nothing of Drawable or Transformable, so its Drawable table still addresses the base DrawShowing() at 0x005066f0, which draws nothing. Drawing belongs to Rnd::PsParticleSys.
Particles live in two places at once. The pool is a vector of 0x80-byte records that the constructor sizes to ten. The live set is a doubly linked list threaded through Particle::mNext and Particle::mPrev from mLiveParticles, and the unused records of the pool form a free list threaded through Particle::mNext from mFreeParticles of the owning system. AllocParticle() and FreeParticle() move one record between the two lists, and each receives a system in $a0 and reads mParticlesOwner, mLiveParticles, and the free list of the owner through it. Releasing a particle that is already free reports "Tried to refree particle from ".
Geometry is shared rather than copied, in the same arrangement Rnd::Mesh uses. A system whose mParticlesOwner is another system draws that system's particles.
The parameter block from +0x108 to +0x1f3 is named from the text dump at 0x00521f40, which reads each member under its label in the order "life:", " posLow:", " posHigh:", "speed:", " pitch:", " yaw:", "emitRate:", " size:", the four colours, " collide:", " collidePlane:", "force:", " mat:", " mode:", "numParticles:", " lineLength:", "bubblePeriod:", " bubbleSize:", "bubble:", and " readZ:". The dump reads "numParticles:" from the size of the pool.
Primitive a system draws each particle as.
The three literals come from the mode printer at 0x0052c6a8, which writes "Point" for zero and "Line" for one, and from the unreferenced literal "Sprite" at 0x00827950. The printer has no case for the third value, so a sprite system dumps no mode at all. That gap is in the shipped build rather than in this reconstruction.
| Enumerator | |
|---|---|
| kModePoint | One GS point per particle. |
| kModeLine | One GS line from mPrevPos to mPos per particle. |
| kModeSprite | One GS sprite per particle. |
| Rnd::ParticleSys::ParticleSys | ( | const HxStr & | name | ) |
Construct an empty system that owns its own particles.
Sizes the pool to ten particles, points mParticlesOwner at this system, writes the default parameters, and then threads the free list through AddObjectRefs().
| name | The object name, passed to the Rnd::Object constructor. |
|
virtual |
|
static |
Allocate a particle system under the tag "Rnd::ParticleSys".
| nSize | The object size the compiler supplies. |
|
static |
Release a particle system block under the same tag.
| pBlock | The block. |
|
virtual |
Write the system to the engine text sink.
| sink | The text sink. |
Reimplemented from Rnd::Animatable.
|
virtual |
Serialise the system.
| stream | The stream to write to. |
Reimplemented from Rnd::Animatable.
Replace one object reference with another.
Forwards to the three bases, then retargets mMat and mParticlesOwner. Losing the particle owner to a null replacement copies the owner's pool and makes this system its own owner.
| pFrom | The object being replaced. |
| pTo | The object to point at, which may be null. |
Reimplemented from Rnd::Animatable.
|
virtual |
Return the registered class name, "ParticleSys".
Implements Rnd::Object.
|
virtual |
Copy another system over this one.
Forwards to the three bases, releases this system's object references, and copies every parameter except mLineLength. Without kCopyShareParticles a source that is its own particle owner gives this system a copy of the pool. Otherwise this system shares the source's owner, and its own pool is emptied unless that owner is this system. The references are then taken again.
| pSource | The source object. The binary dereferences the cast result without a null check, so a source that is not a system faults. |
| nFlags | The copy flags. |
Reimplemented from Rnd::Animatable.
|
virtual |
Load the system.
Reports "Can't load new ParticleSys" through the failure sink when the file version exceeds what this build writes.
| stream | The stream to read from. |
Reimplemented from Rnd::Animatable.
|
virtual |
Restart the emission and release every live particle.
Rnd::Animatable vtable slot 2. Releases the live list and then chains to Rnd::Animatable::StartAnim(). This is the only override of that slot in the shipped build, so it is also the evidence the slot's title rests on.
Reimplemented from Rnd::Animatable.
| void Rnd::ParticleSys::FreeAllParticles | ( | ) |
Release every live particle back to the pool of its owner.
The walk unlinks each particle from the live list and pushes it onto the free list of mParticlesOwner. A particle whose mPrev is null is already free, and releasing one reports "Tried to refree particle from " with the name of the system. The head of the live list stores its own address in mPrev as the marker that distinguishes it from a free particle.
| Particle * Rnd::ParticleSys::AllocParticle | ( | ) |
Take one particle from the pool of the owner and push it onto the live list.
The free list is threaded through Particle::mNext and terminates at the finish pointer of the pool vector, so an exhausted pool is the head equalling that pointer. The new particle becomes the head of the live list and stores its own address in mPrev.
Unlink one live particle and push it onto the free list of the owner.
A null particle yields null. A particle whose mPrev is null is already free. Releasing it reports "Tried to refree particle from " with the name of the system and yields null. The routine was previously labelled as a Rnd::Generator member, and a Generator is one of its callers.
| pParticle | The particle to release, or null. |
| void Rnd::ParticleSys::RandomizeColorAndSize | ( | Particle * | pParticle | ) |
Draw a random spawn colour and size for one particle.
Each of the five values is an independent draw from the 31-bit generator at 0x0054f770, scaled by 2 to the power of -31 and interpolated from the high bound toward the low one. The four colour components come from mStartColorLow against mStartColorHigh and the size from mSizeLow against mSizeHigh. Neither the position nor the velocity of the particle is touched.
| pParticle | The particle to write. |
| void Rnd::ParticleSys::SetMat | ( | Mat * | pMat | ) |
Point the system at a material, moving its reference registration from the old one.
The body is inline. The only copy in the image is an out-of-line emission with no caller, and the name is inferred.
| pMat | The material, or null. |
| void Rnd::ParticleSys::SetParticlesOwner | ( | ParticleSys * | pOwner | ) |
Draw the particles of another system, or of this one.
Releases the object references, stores the owner, and takes the references again. A system that no longer owns its particles then empties its own pool. The body is inline. The only copy in the image is an out-of-line emission with no caller, and the name is inferred.
| pOwner | The system whose particles to draw. |
|
inline |
Report the head of the live list.
The out-of-line copy has no callers. Rnd::Generator::SetFrameSelf() and Rnd::Generator::DrawShowing() inline it.
|
inline |
Replace the force every particle accelerates by.
The out-of-line copy has no callers. TnlEmitter inlines it.
| force | The force. |
|
inline |
Report the force every particle accelerates by.
The out-of-line copy has no callers. TnlEmitter inlines it.
|
protectedvirtual |
Advance the emission to a frame.
Rnd::Animatable vtable slot 3. Returns at once while mLastFrame still stores its unset sentinel. Otherwise it integrates the live particles over the elapsed frames and then spawns whatever the emission rate calls for.
| flFrame | The filtered frame to animate to. |
Reimplemented from Rnd::Animatable.
|
protected |
Resize the particle owner's pool, the count the dump labels "numParticles:".
The owner's references are dropped around the resize and taken again, which rethreads the pool onto the free list and empties every sharer's live list. New records are copies of one whose vector padding words are 1.0. No call site survives in the shipped program, and the name is inferred from the dump label.
| nCount | The new pool size. |
|
staticconstexpr |
Copy() flag that shares the source's particles rather than copying its pool.
|
protected |
| std::vector<Particle> Rnd::ParticleSys::mParticles |
< Pool the live list draws from, which the constructor sizes to ten records of 0x80 bytes. Public rather than protected because Rnd::PsParticleSys::DrawShowing() measures it through mParticlesOwner, which is a Rnd::ParticleSys * and need not be a PsParticleSys, and protected access cannot reach a member through a pointer to the base type. The image exposes no accessor for it. +0xe8
|
protected |
| float Rnd::ParticleSys::mEmitRateLow |
< Low end of the emission rate range. Public because Rnd::ParticleSysAnim::SetFrameSelf() writes it from outside the hierarchy and the image exposes no accessor. A friend declaration fits the image equally well. +0x158 High end of the emission rate range. Public on the same evidence as mEmitRateLow. +0x15c
| float Rnd::ParticleSys::mEmitRateHigh |
Low end of the size a particle spawns with, which RandomizeColorAndSize() draws against mSizeHigh. Public on the same evidence as mEmitRateLow. +0x160
| float Rnd::ParticleSys::mSizeLow |
High end of the size a particle spawns with. +0x164
| float Rnd::ParticleSys::mSizeHigh |
| Color Rnd::ParticleSys::mStartColorLow |
< Low end of the colour a particle spawns with. Public on the same evidence as mEmitRateLow. +0x170 High end of the colour a particle spawns with. +0x180
| Color Rnd::ParticleSys::mStartColorHigh |
Low end of the colour a particle fades to. +0x190
| Color Rnd::ParticleSys::mEndColorLow |
High end of the colour a particle fades to. +0x1a0
| Color Rnd::ParticleSys::mEndColorHigh |
| Mat* Rnd::ParticleSys::mMat |
< Material every particle draws with, or null for the default surface. Public because Rnd::PsParticleSys::DrawShowing() selects it through a Rnd::Mat * and the image exposes no accessor. +0x1e0 Primitive each particle draws as. Public on the same evidence as mMat, the draw path switching on it directly. +0x1e4
| Type Rnd::ParticleSys::mMode |
| int Rnd::ParticleSys::mReadZ |
< Non-zero to depth test the particles. The draw path programs TEST_1.ZTST from it, GREATER when set and ALWAYS when clear. +0x1ec The dump label " lineLength:" names it. The draw path passes it to PackParticleQuads(), whose line mode takes the second end point of each line from the quadword this many past Particle::mPos. +0x1f0
| int Rnd::ParticleSys::mLineLength |