Game Development Reference
In-Depth Information
How It Is Used
The force-based pivot algorithm works in a different way from the engine we've been
building in this topic. In our engine, forces are accumulated and applied, and then
collision detection and response occurs.
The Jacobian includes the calculations for applying forces, however, so everything
is done in one go: contact forces are calculated and applied along with the rest of the
forces.
There are three problems this raises, however: When do we do collision detection?
How do we handle interpenetration? What about non-resting contacts?
The architecture of different physics engines handles these steps in different ways.
Thesecondtwoproblemsareoftenapproachedinmuchthesamewayaswehave
them in our engine (but removing micro-collisions: if two objects are determined to
be in resting contact, then they are handled by the force system). Separate collision
and interpenetration steps are taken after the forces have been applied.
In some engines the collision response is performed first, and its results are em-
bedded in the known force vector and incorporated into the force calculations dis-
cussed before. This relies on the fact that if we know the length of time for one update
frame t ,thenwecanconvertanimpulse g into a force f using the formula
f
=
gt
allowing us to represent the calculated collision impulse as if it were just another force
applied to the rigid body.
The first problem is more sticky: when do we perform collision detection? If we
perform collision detection at the start of the frame, before the force calculations,
then the result of applying the forces may cause new collisions that will still be visible
when the objects are next drawn.
If we perform collision detection after the force calculation, then we can remove
all interpenetration before the user sees the frame. But how do we determine the
contacts we need to fill in the Jacobian at the start of the frame?
We could do both, but that would be very time consuming. In effect the second
solution is what is normally used.
The collision detection is performed before interpenetration is resolved, and the
user sees non-interpenetrating bodies. The same collision data is then stored until
the next update, and it is used to fill the Jacobian. This affords a good compromise
between efficiency (extra data is stored between frames) and removing visible inter-
penetration (which is typically very obvious to the viewer).
As I mentioned in chapter 12, commercial systems often improve efficiency fur-
ther by using frame coherence: keeping track of the last frame's collisions to speed
up collision checks at this frame. If the collision detector does this, then the data is
already being stored and can be made available to the physics engine.
Search Nedrilad ::




Custom Search