2
\$\begingroup\$

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.

\$\endgroup\$
  • 1
    \$\begingroup\$ possible duplicate of How to separate colliding objects without creating more collisions \$\endgroup\$ – Icy Defiance Aug 29 '14 at 14:05
  • \$\begingroup\$ @Icy: Thanks for the link. I have already seen that question. But my problem is different. In my case, the initial configuration (poses) of the objects given to my collision resolver engine might be overlapping. At the first step, I would like to be able to make all overlapping volumes between each pair of objects zero, and then running a physics simulation for the resolved configuration... \$\endgroup\$ – Rasoul Aug 29 '14 at 14:11
  • \$\begingroup\$ @Rasoul That still makes this a special case of the more general problem. \$\endgroup\$ – Anko Aug 30 '14 at 20:57
2
\$\begingroup\$

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

\$\endgroup\$
  • \$\begingroup\$ 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... \$\endgroup\$ – Rasoul Aug 29 '14 at 14:27
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Roy T. Aug 29 '14 at 17:34
  • \$\begingroup\$ 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. \$\endgroup\$ – DoubleDouble Mar 1 '16 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.