# Force propagation thought several contacting bodies.

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

## Recommended Posts

I am making a game with lots of particles that have to collide with each other. This will be in 2d and each particle is the same mass and same size. How do I get forces to propagate through several contacting bodies in one physics frame. For example: Although this is an over simplified 1D example. In 2D there can be large clumps particles and if they are up against an unmovable object the forces will behave differently. The problem I see is that I can’t know order of the particles the force will pass thought with regards to how I have them in a container, and it will take several frames to properly propagate the force. Assume that the in the image above the balls are not in the order in their container that they appear on the screen. Assume that they are in reverse order, the first ball in the container is the right most ball, and the last ball in the container is the one that’s initially moving. If I update my the objects by iterating thought the container from front to back I will have to update the world 6 times after the initial collision to get the last ball in the end to move. What can I do to solve this? In this simple example I could iterate through the objects by following contacts but I don’t think that would be practical in a 2D mass of particles. It could potential lead to infinite loops and discontinuous particles will be skipped.

check:

##### Share on other sites
If your particles are not deformable (in your simulation) then the effect will be propogated through instantaneous impulses not forces - Each physics step iterate through the system processing each collision (doesn't matter hugely what order) until all the collisions are resolved (have a zero or separating velocity). Subsequently process contacts either iteratively or simultaneously using a LCP solver.

However, as you indicate, for a big system of interacting objects the number of collision iterations is going to be very large. So, you can stop the collision processing early (depending how much CPU time you've got to burn) - so long as you do the contact solving step afterwards (and if you use an iterative method for that, then so long as you don't terminate _that_ early), then the error in your solution will/may be big if your particles were colliding elastically, and should be small if colliding inelastically.

##### Share on other sites
Quote:
 Original post by MrRowlIf your particles are not deformable (in your simulation) then the effect will be propagated through instantaneous impulses not forces - Each physics step iterate through the system processing each collision (doesn't matter hugely what order) until all the collisions are resolved (have a zero or separating velocity). Subsequently process contacts either iteratively or simultaneously using a LCP solver.
I'm not sure how order doesn’t matter?

Lets say I had and array of particles
Particle particles[Max_Particles]

And they are arranged spatially like this in.
* ******6 543210

And the code to update the simulation went something like this
for(int i=0; i<Max_Particles; i++){    check for contacting particles against particle        transfer forces between particle and contacting particle}for(int i=0; i<Max_Particles; i++){    update velociy    move particle}

When the code iterates the first time only the particles 5 & 6 will be affected by the collision. Particles 1-4 aren’t touching any particles that have a force acting on them. When particle 4 is processed the first time around particle 5 isn’t doing anything yet, so no force or impulse is passed to 4. 4 will be affected by the impulse during the next physics step. Then particle 3 the step after that and so on.

It would look something like this
> ****** >>***** *>>**** **>>*** ***>>** ****>>* *****>> ****** >

##### Share on other sites
Quote:
 Original post by Grainfor(int i=0; i

You would need to change this to

for (int iter = 0 ; iter < maxIter ; ++iter){    bool allCollisionsResolved = true;    for(int i=0; i<Max_Particles; ++i)    {        check for contacting particles against particle            transfer forces between particle and contacting particle and set allCollisionsResolved = false    }    if (allCollisionsResolved) break}

(the loop increment seems to get eaten by gamedev - at least in the preview!)

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 11
• 28
• 15
• 39
• ### Forum Statistics

• Total Topics
634835
• Total Posts
3019539
×