Particle Engine with no Limits?

Started by
9 comments, last by neonfaktory 20 years, 9 months ago
Why set a limit to the number of particle systems at all? Take a look at this article at gamasutra (you may need to register first but it''s free and it really worth it). It takes a three step approach:

1) Particle systems manager
2) Particle systems
3) Particles

The manager keeps a std::vector to keep track of the particle systems. There''s no limit to the amount of systems. Each system dynamically allocates enough memory to hold all the particles in that one system. These particles get reused over and over again until the system dies or is shut down. After that, the memory block for the particles is being released.

If you would combine this method with the memory garbage collection from the Enginuity part II article, you''d have a nice, memory friendly particle system with unlimited capacity (well, maybe physical memory and rendering speed. But it''s not limited in your code anymore).

Quick example: Say you want some smoke coming from your gun. You would call something like this:

ParticleManager.Init(SMOKE_SYSTEM, numParticles, position);

SMOKE_SYSTEM is just a predefined integer to indicate the type, position is a vector. The manager pushes a new smoke system, derived from a generic particle system class, into the std::vector. The newly created system then dynamically creates an array like particles = new CParticles[numParticles]; to hold all the particles. When the system dies, the smoke system deletes[] the particles and after that, the manager removes the system from the std::vector.


Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

This topic is closed to new replies.

Advertisement