Originally Posted by
User137
Keep in mind having too many variables per particle can effect greatly on memory use and speed when it comes to use large amount of particles.
The particle struct is 104 bytes, so thats not that bad, even 100k particles wont take that much memory.
Code:
PPHXParticle = ^TPHXParticle;
TPHXParticle = record
// The number of seconds since the birth of the particle
Time : Single;
// The energy of the particle
Energy : Single;
// The lifetime of the particle
Life : Single;
// The size
Size : Single;
// Pattern index of the particle
Pattern : Byte;
// The color
Color : TColor4f;
// The color fade
Fade : TColor4f;
// The position
Position: TVector3f;
// The velocity
Velocity: TVector3f;
// The acceleration
Acceleration : TVector3f;
PrevPosition: TVector3f;
PrevTime : Single;
end;
Originally Posted by
User137
Haven't tested how fast/slow it would be if each particle was an object. (don't know if they already are objects in your system) In that case it would be possible to make different versions of particles and optimize using only variables that are needed; as sub object types. This would also give renderer more flexibility and options. Like when group of particles share same properties they would only be set once at renderer instead of 20000 times.
The problem with making the particles an object, except that you have some construct overhead is that to make it any usefull you'll have to have virtual methods for the render and update function, for each particle.
In the current version the particle system manages the updating for each particle without a function call and the manager renders the particle systems using 2 function calls per system, it batches all particles and renders then per system basis (Going to test so it only calls one a system parameter is updated (texture or blending) but i'm not shure if it will bring any greater speed increases).
Bookmarks