Game Development Reference
In-Depth Information
For physics engines in particular, there are a couple of common bugbears that
you are almost guaranteed to see during development: sudden, unexpected motion—
when an object leaps of the ground, for example—and objects disappearing. The code
on the CD shouldn't display either of these critical problems, but chances are you'll
see both before long if you make changes and tweaks.
The stability problems we are left with should be more minor, but their causes fall
into all three categories. By carefully testing the engine I identified five problems that
have relatively easy stability fixes.
Transform matrices can be malformed and perform skews in addition to ro-
tations and translations.
Fast-moving objects can sometimes respond oddly to collisions. (This is inde-
pendent of whether the collisions are actually detected: a fast-moving object
can pass right through another object without a collision being detected.)
Objects resting on an inclined plane (or resting on another object with a slop-
ing surface) tend to slowly slide down.
Objects experiencing a pair of high-speed collisions in rapid succession can
suddenly interpenetrate the ground.
The simulation can look unrealistic when large and small quantities are
mixed: large and small masses, large and small velocities, large and small ro-
tations, and so on.
Fixes for these stability problems solved the odd behaviors my tests generated. Of
course no test is ever going to be exhaustive. I have used physics systems for years
before noticing some new issue or error.
As with all software maintenance, you never know when some change will need to
be made. And by the same token it is a good idea to keep a copy of the test scenarios
you run on your engine, so you can go back and check that your new enhancement
hasn't broken anything else.
Transform matrices are generated from the position vector and orientation quater-
nion of rigid bodies. Both position and orientation (in fact all values that take part in
mathematical manipulation) suffer numerical errors while being processed.
Errors in the position vector put an object in the wrong place. This is usually such
a small error that it isn't noticeable in any short period of time. If the position changes
slowly enough, the viewer will not notice any errors.
The same is true of the orientation vector to some extent. But there is an ex-
tra problem: we have an additional degree of freedom in the quaternion. If the four
quaternion components get out of sync (i.e., if the quaternion is no longer normal-
ized), then it may not correspond to any valid orientation. None of the code in our
engine is particularly sensitive to this, but left for long enough it can cause objects to
become visibly squashed. The solution, as we saw in chapter 9, is to renormalize the
Search Nedrilad ::

Custom Search