Particle System

Started by
1 comment, last by ItsDoh 17 years, 2 months ago
I wanna add a particle system to my engine, but I'm not sure about some things. Let's say I have an array of particles and an array of forces (attractors, repulsors - like a black hole for example, and directional forces). For the directional forces is easy, just add the directional vectors, but for the others... How can I compute the velocity of a particle per frame related to a attractor/repulsor (the far particles should be affected less) without having to find out the distance between each particle and each force generator each frame? If I do that I'm sure the frame rate will really drop...
Advertisement
In short, you can't. There are some optimizations, but they come at the cost of memory or accuracy. You could divide the space up into lots of sub-regions and precompute a total force in each sub-region. Then at run-time, you do a lookup based on the particle's position. Also, keep in mind that forces such as gravity are proportional to the square of the distance, which means that no square-root computation is necessary.

You should just try it using brute force. My prediction is that unless you have a lot of forces and/or a lot of particles, you won't see much of a slow down.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Unless super-accurate physics was required and a 'good-enough' solution wasn't good enough, couldn't you just update a portion of the particles per-frame?

Meaning you check say 1/3rd of the particles per frame, but when the particles are updated use 3x the attractor/repulsor force? The effect would be that the particles would be just slightly off a physics-accurate position, but unless they were moving really fast I can't see it affecting it...

Just food for thought. I'm no particle system expert and haven't done any real implementation stuff on it yet.

[Edited by - ItsDoh on January 28, 2007 2:06:03 PM]

This topic is closed to new replies.

Advertisement