I've encountered quite a few bad errors in the current engine, the allocating of systems is far from fast, and a few bits and pieces is way to slow and lacking in features.
Thus I've have some serious thoughs on rewriting it.
With this in mind I've posted this to hear what you'd like from a particle system.
I think the system/effect method in the old engine is the way to go
I've written some prototype code so far, for instance the following code attatches a particle system to a tag in a model (ie it will move with the missile, rotating translating, you name it).
Code:
with ParticleManager.AddSystem(Spark) do begin
Attatch( TPHXTag(Missile1.Tags[0]).Final );
end;
In my test the particles supports both time based and distance based particles, with burst possibilities.
Code:
EmissionMethod: TPHXEmisionMethod; // emTime, emDistance
// Delay between each emission
EmissionDelay: Single;
// Nuber of particles to emit each cycle
EmissionCount: Integer;
// Time to wait before starting the emission
EmissionStart: Single;
Also added pattern support (1x1, 2x2, 4x4 or 8x8 in size) thus it's possible to animate the particle textures, uses fixed rectangular patterns for speed.
It's possible to have various shapes of the particles, axis alinged in x,y,z (x,y are quite useless for pure 2D but it's a simple lookup anyway), billboarded and trail (a quadstrip going between each particle, like engine trails and so forth). May add a sixth wich is a spark, ie the particle is drawn as a rotated quad between the last and current position.
I've added the following emision properties for each particle to the effect, exept for texture and shape as is a system property
Code:
// Pattern
Pattern: Byte;
// Particle lifetime
LifeMin: Single;
LifeMax: Single;
// Particle size
SizeMin: Single;
SizeMax: Single;
// Particle start and end color
ColorStart: TColor4f;
ColorEnd : TColor4f;
// Emission points, each particle gets assigned one at random
EmisionPoints: TVectorList3f;
// Position variance
PositionMin: TVector3f;
PositionMax: TVector3f;
// Direction
DirectionMin: TVector3f;
DirectionMax: TVector3f;
// Spherical velocity
VelocityMin: TVector3f;
VelocityMax: TVector3f;
// Acceleration vectors
AccelerationMin: TVector3f;
AccelerationMax: TVector3f;
As you see some of the properties from the old system is gone, for instance the color lists, radial and tangential acceleration. However each effect has a list of particle affectors that may affect the particles in varius ways. So far i've written a gravity affector and a bounce affector.
Code:
Procedure TPHXParticleAffector.Affect(System: TPHXParticleSystem; const Particles: TPHXParticleList; FrameTime: Single);
On the rendering side, each particle system is no longer required to render its own particles and the systems is sorted by textures for less state changes. Also a particle system isnt disposed of until the manager is destroyed, it reuses dead ones instead, memory improvement aswell.
So now's the time for your thoughts, something i've missed that's a must ?
Bookmarks