Game Development Reference
In-Depth Information
A better solution is to keep all the sets of data together in a separate array:
AIData ai[256];
Geometry geometry[256];
Material material[256];
Texture textures[4][256];
RigidBody physics[256];
CollisionGeometry collisionGeom[256];
For large game levels this still won't be enough. In this case it is worth ordering the set
of rigid bodies such that objects in different areas of the game level are kept together.
That way, when contacts are processed, the bodies involved are likely to appear in the
cache together. Contacts will not be generated between objects across the level from
each other, so they can be separated in the array.
Cache misses are notoriously difficult to diagnose, and their prevalence tends to
change dramatically when you add debugging code or make seemingly unrelated ad-
justments. A good profiler is essential.
16.3
S UMMARY
By simply adding sleeping objects and tolerance for near-collisions you will have a
reasonably efficient physics engine. It's time now to look at how it can be used in some
real game applications. If you are creating your own engine as you follow through
this topic, it's time to put it through its paces. If your profiler detects performance
problems, you can return to this chapter and try some of the other optimizations.
Chapter 17 reviews what we have and looks at how the key physics effects seen in
many recent games are achieved.
Search Nedrilad ::




Custom Search