Original Post
I''m unsure as to the general top-level algorithm to use in simulating rigid bodies and dealing with collisions?
I was thinking it would go something like this -
- Clear force and torque accumulators on all objects
- Apply external forces like weight, wind, thrust, etc. to all bodies.
- For all objects: Update position, orientation, linear and rotational momentum, based on the accumulated forces. Ignoring collisions/interpenetration for now.
- Clear force and torque accumulators again.
- For all objects: Check for interpenetration with every other collideable body/object
- For each object the body is penetrating: Backtrack both objects'' positions and orientations to the time when they made contact. Determine the contact points at this time and apply force and torque to both objects in response to the collision contacts.
- For all objects: if this object has accumulated more force and torque, as a result of a collision, then update position, orientation and momentums again, to take them from the collision time (to which they had been backtracked) back up to the current time again.
However, doing this causes problems: If, for example I''m checking object A for penetration with other objects. I first check it against B to find that it is not penetrating, then find it is penetrating object C. I’d determine the contact point, and update object A and C in response to the collision. However, the response to the collision with C might now mean that A is now penetrating object B!
Unless, you would continue repeating the collision tests, backtracking, and updating until there were no more collisions.
Is there a better way to approach the top-level simulation or get round the ''collision response causing a new collision'' problem?
Thanks in advance.
Dan.