2

I have working functions that compute the overlapping polyhedron, contact points, depth of penetration (DOP), etc. of the overlap between two objects with convex polyhedra shapes.

I know how to resolve the collision between two colliding movable objects, for example by moving one of them DOP units along the penetration normal.

Problem: What is a simple method to resolve collisions between more than two objects? For example, let's say objects A, B and C are in collision such that A overlaps with B, and B overlaps with C. If I move A to resolve its collision with B, then A might overlap with C (or any other object in the scene), and now if I resolve the collision between A and C, one of them might overlap with another object. To me, it seems an endless chaining effect. Is there any standard algorithm to resolve collisions between more than two objects simultaneously (batch collision resolving) such that at the end of the day, there are no pairs of objects overlapping?

Note: In my problem statement it is assumed that a scene initially filled with possibly overlapping objects with convex polyhedron shapes is given to my collision resolver engine.

Rasoul
  • 121
  • 5

1 Answers1

2

Separate your collision detection in to two phases: Collision Detection and Collision Resolution.

In the first step find all obstacles that collide with object A. Then compute for each obstacle the vector and force required to resolve the collision.

In the second step add all vectors/forces together and apply them to object A.

This is a simple and effective way to solve most collisions when there are not too many things to collide with. More advanced solutions exist. For that take a look at this answer How to separate colliding objects without creating more collisions (also linked by Icy Defiance in the comments).

Roy T.
  • 10,208
  • 34
  • 56
  • I see your point, but applying a force to object A to resolve its collision with B and C, might end up with a configuration in which A is now in collision with some other object(s), if I do the same calculation for this new set of collision, A might end up in collision with another set of objects... Indeed, I'm looking for a pure geometrical solution to first resolve the overlapping between all the objects with minimum change in their initial poses... – Rasoul Aug 29 '14 at 14:27
  • 1
    I don't think there is a closed form algorithm usable in games that guarantees no collisions. In fact there are real-life scenarios in which there would be no solution. For example three cars driving into each other. There is no way for the center car to not stay in contact with the other two cars. Of course you don't want it bouncing around so you can run this algorithm several times, with some dampening on the forces, per frame for obstacles that keep colliding with something. – Roy T. Aug 29 '14 at 17:34
  • Taken literally, the "real life solution" deforms the cars. If the cars could not deform, as in many games, it would be more like raising both ends of a newton's cradle - though I figure you are assuming both cars colliding against the middle car and letting the forces cancel out is not acceptable in your scenario. – DoubleDouble Mar 01 '16 at 03:20