I've been reading around that its a good thing to allow some penetration. And it really seems hard to keep bodies separated, after position/orientation update for example. But how can I allow penetrations if I'm detecting collisions?
If a pair of bodies penetrate after velocity integration, a collision will be detected, and in the worst case the simulation may get stuck. One detail is that a pair of bodies that are in contact can still collide...
Thanks. .
CCD and penetration? How?
-
- Posts: 33
- Joined: Fri Feb 01, 2008 9:44 am
Re: CCD and penetration? How?
I think the point is to allow some penetration in the CCD calculations. When CCD is used with physics, the objective is to catch and process discontinuities (read: collisions) in the simulation at the time they happen, so that the overall simulation is physically correct. This is in contrast to physics with discrete collision detection where discontinuities are only detected at discrete intervals and it is possible for discontinuities to be missed completely (tunneling, or collisions which happen when an object is on the rebound from hitting something else), or dealt with unrealistically (i.e. very deep penetration making it hard to work out the 'correct' way that objects should be separated).
Typically, this is done by detecting the first TOI (time of impact), progressing time to this point, resolving collision forces, then repeating this process until the desired time step has passed. This process can be optimized in various ways, but that isn't the point here. The problem with this type of scheme is that when objects are in light contact it is possible for very small TOIs to be calculated and the simulation begins to grind to a halt, also floating point precision can start to become a problem and then things become unstable.
Allowing some penetration is a way of dealing with this issue. Shallow collisions can generally be dealt with safely, efficiently, and plausibly using methods like Baumgarte position correct, split impulses, or maybe even some sort of position projection.
In terms of the CCD (and this is the way I have implemented it), if two objects are found to be in shallow penetration at the end of the time step, I effectively ignore their penetration, and return a TOI of 1.0f. As a caveat, you need to make sure the objects have not tunneled and are in shallow penetration on the 'wrong side', but this can be determined from the swept collision calculation. By ignoring shallow penetrations in the calculation of the first TOI, I am effectively reserving continuous physics to deal only with problematic situations which I really care about, like very deep penetration and tunneling. It also means that far fewer discontinuities are dealt with in the continuous physics loop, making it fast and preventing it grinding to a halt.
This doesn't give a 100% physically correct simulation at all times, but I think it is a great solution for games.
Hope this helps!
Cheers,
Rob
Typically, this is done by detecting the first TOI (time of impact), progressing time to this point, resolving collision forces, then repeating this process until the desired time step has passed. This process can be optimized in various ways, but that isn't the point here. The problem with this type of scheme is that when objects are in light contact it is possible for very small TOIs to be calculated and the simulation begins to grind to a halt, also floating point precision can start to become a problem and then things become unstable.
Allowing some penetration is a way of dealing with this issue. Shallow collisions can generally be dealt with safely, efficiently, and plausibly using methods like Baumgarte position correct, split impulses, or maybe even some sort of position projection.
In terms of the CCD (and this is the way I have implemented it), if two objects are found to be in shallow penetration at the end of the time step, I effectively ignore their penetration, and return a TOI of 1.0f. As a caveat, you need to make sure the objects have not tunneled and are in shallow penetration on the 'wrong side', but this can be determined from the swept collision calculation. By ignoring shallow penetrations in the calculation of the first TOI, I am effectively reserving continuous physics to deal only with problematic situations which I really care about, like very deep penetration and tunneling. It also means that far fewer discontinuities are dealt with in the continuous physics loop, making it fast and preventing it grinding to a halt.
This doesn't give a 100% physically correct simulation at all times, but I think it is a great solution for games.
Hope this helps!
Cheers,
Rob