Hi again, I'm back for more knowledge. I am building a particle system. I have just knocked one up quickly.
It is structured thus:
An entity can have a particle emitter component which contains a collection of particles (an arbitrary class at the moment) with certain data like other components, physics, transform etc.
A particle emitter scene node is added to the scene graph and it passes commands to the renderer for all of the particles in the emitter components collection.
I have implemented the physics separately from my current custom physics implementation because the particles aren't game entities current one has a lot of entity specific code at the moment (this made it clear it needs refactoring , decoupling). (Actually i just had a thought that i can subclass the physics component to handle particle emitters differently).
And then there is a particle system that calls update for all particle emitter components and they handle spawning new particles.
I considered having particles as entities themselves because then they could simply be composed of all my existing components for collision, physics, rendering and whatever else. But because the lifespan of particles will be variable but generally short and its possible for there to be thousands of them I think the entity collection is not a good option.
I am after some design ideas and hints if there are any available. I remember when i built one years ago i had a particle buffer built on initialization and then used only that allocated space for particles. I tried that initially and then decided to just get it to work first. It's working now, but needs to be refined.
I appreciate any hints, you guys always point me the right way.
It is structured thus:
An entity can have a particle emitter component which contains a collection of particles (an arbitrary class at the moment) with certain data like other components, physics, transform etc.
A particle emitter scene node is added to the scene graph and it passes commands to the renderer for all of the particles in the emitter components collection.
I have implemented the physics separately from my current custom physics implementation because the particles aren't game entities current one has a lot of entity specific code at the moment (this made it clear it needs refactoring , decoupling). (Actually i just had a thought that i can subclass the physics component to handle particle emitters differently).
And then there is a particle system that calls update for all particle emitter components and they handle spawning new particles.
I considered having particles as entities themselves because then they could simply be composed of all my existing components for collision, physics, rendering and whatever else. But because the lifespan of particles will be variable but generally short and its possible for there to be thousands of them I think the entity collection is not a good option.
I am after some design ideas and hints if there are any available. I remember when i built one years ago i had a particle buffer built on initialization and then used only that allocated space for particles. I tried that initially and then decided to just get it to work first. It's working now, but needs to be refined.
I appreciate any hints, you guys always point me the right way.