# Particle System

This topic is 4334 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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...

##### Share on other sites
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.

##### Share on other sites
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]

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5
khawk
14

• 9
• 11
• 11
• 23
• 10
• ### Forum Statistics

• Total Topics
633652
• Total Posts
3013146
×