Collision problem that I've always had

Started by
7 comments, last by Daniel Miller 17 years, 1 month ago
This is extremely simple, but I'm not sure what the best way to solve it is. Let's say you have a large number of objects in a line, like this:
xxxxx          ooooo
Then, each side starts moving towards each other at a quick speed:
  xxxxx-> <-ooooo
What happens when the middle two collide and then intersect? You can't just move them back, because then you have even more collisions. What am I supposed to do?
Advertisement
Quote:Original post by Daniel Miller
What happens when the middle two collide and then intersect? You can't just move them back, because then you have even more collisions. What am I supposed to do?



you move them back by how much they are intersecting.
I think it depends on your collision model. I think one model is:

1) move an object
2) test for collision
3) do collision response
4) goto 2 until there are no more collisions
5) goto 1 until there are no more objects to move

I think there are much more efficient models, but I'm just beginning to learn about that ATM. "Verlet Integration" would be something good to google; there are a few articles about designing physics systems built around verlet integrators.

-me
Quote:Original post by Palidine
I think it depends on your collision model. I think one model is:

1) move an object
2) test for collision
3) do collision response
4) goto 2 until there are no more collisions
5) goto 1 until there are no more objects to move

I think there are much more efficient models, but I'm just beginning to learn about that ATM. "Verlet Integration" would be something good to google; there are a few articles about designing physics systems built around verlet integrators.

-me


That's the thing. If more than one object is traveling in the same direction, then you may detect a collision when there really isn't one (because the other object may be moving out of the way). Thanks a lot for your help in this thread and in my RTS thread, btw. :)
Quote:Original post by Daniel Miller
That's the thing. If more than one object is traveling in the same direction, then you may detect a collision when there really isn't one (because the other object may be moving out of the way). Thanks a lot for your help in this thread and in my RTS thread, btw. :)


Maybe you should check into some sort of recursion where each movable object passes it's inertia onto other movable objects it collides with. That way, all collisions will cascade until either the object hits nothing or hits something that is not movable.

[edit] I should mention that this is only theoretical since I've not successfully implemented collision detection, yet. [/edit]
I've got a demo of two sets of objects moving towards each other in tutorial 4 of Jabuka (shameless plug, see sig).

I'm not currently moving any objects back on intersections, but am unwinding the simulation until I find the time of intersection and then doing the collision response.

"you move them back by how much they are intersecting." I think that the OP's problem is that if he moves only the intersecting objects back, then he'd be pushing them into the objects following the lead object. That's why I'm winding back all objects in the simulation.

If you don't want to do wind back the simulation, lots of people in the Maths & Physics forum have had luck implementing shock propagation via this paper: http://graphics.stanford.edu/papers/rigid_bodies-sig03/

"If more than one object is traveling in the same direction, then you may detect a collision when there really isn't one (because the other object may be moving out of the way)."

My code checks for these situations - if a collision is reported it adds an extra check to see whether the objects are separating, but it does seem pretty clunky.

hope this helps.
C# Physics Engine Tutorials: www.taumuon.co.uk/jabuka/
My objects have no inertia, so here is what I'm thinking of doing:

1. Move every object
2. Detect collisions for moved objects
3. If anything collides, move them to a position where they are no longer colliding, and detect collisions again

Thanks for the replies!
Quote:Original post by Daniel Miller
My objects have no inertia, so here is what I'm thinking of doing:

1. Move every object
2. Detect collisions for moved objects
3. If anything collides, move them to a position where they are no longer colliding, and detect collisions again

Thanks for the replies!


I'd say you don't want to move every object and then check for a collision. You want to move one object, then check. Then move another and check again. And continue doing so until you have moved all objects. This way there's only one possible collision during each check.
Quote:Original post by Artum
Quote:Original post by Daniel Miller
My objects have no inertia, so here is what I'm thinking of doing:

1. Move every object
2. Detect collisions for moved objects
3. If anything collides, move them to a position where they are no longer colliding, and detect collisions again

Thanks for the replies!


I'd say you don't want to move every object and then check for a collision. You want to move one object, then check. Then move another and check again. And continue doing so until you have moved all objects. This way there's only one possible collision during each check.


The problem is if I have several units moving in a line. The objects in the back would detect a collision when they tried to move, when in reality there wouldn't be one because the objects in front are moving in the same direction.

edit: it's English now

This topic is closed to new replies.

Advertisement