Game Development Reference
In-Depth Information
Don
'
t Count Memory Used Only for Debugging
This tip might be a little off the subject, but the last paragraph reminded me of
it, so here goes. Whenever you have memory allocated for diagnostic or
debugging purposes, make sure that you don
s
memory budget! You can send the testers into a panic if they see the
memory budget skyrocket, and the only reason it did so was that you
allocated a couple of megabytes for some debugging routine.
'
t count
it
in your game
'
Another simple yet interesting method is reportErrorWarning :
void BulletDebugDrawer::reportErrorWarning(const char* warningString)
{
OutputDebugString( warningString );
}
The reason you want to send errors and warnings to the debug window is pretty sim-
ple; there is a wealth of information that can help you diagnose problems sitting in
the error stream. You must trap it yourself and send it somewhere useful, such as the
output window in the debugger, a log file, or preferably both. While writing this
chapter, I used this very code to figure out that I was sending in incorrect data
while trying to create a collision hull for a test object. If that
'
s not good advertising,
I don
t know what is.
This version merely forwards the error message to the debug output stream. It
'
'
sa
good start, but there
s a whole world of things you can do with this information,
including popping up a dialog box, recording the data in a database, emailing a mes-
sage to your physics programmer, and so on.
'
Receiving Collision Events
Moving objects around realistically provides a great visual look to your game, but
when objects collide and interact, your game gets really interesting. A collision
event can be defined as when two objects change their contacts either by colliding
or separating. In Bullet, generating these events is a little tricky, but you can do it
by using the internal tick callback. This callback is set up in VInitialize() , and
Bullet calls it once every internal time step. It
s a great place to put any work that
needs to happen continuously within the physics system.
'
void BulletPhysics::BulletInternalTickCallback(
btDynamicsWorld * const world, btScalar const timeStep )
{
GCC_ASSERT( world );
 
 
Search WWH ::




Custom Search