Game Development Reference
In-Depth Information
{
GCC_ERROR(
BulletPhysics::VInitialize failed!
);
return false;
}
m_dynamicsWorld->setDebugDrawer( m_debugDrawer );
// and set the internal tick callback to our own method
//
m_dynamicsWorld->setInternalTickCallback( BulletInternalTickCallback );
m_dynamicsWorld->setWorldUserInfo( this );
BulletInternalTickCallback
return true;
}
This method looks more complicated than it is. This function loads the XML file
holding the materials and density tables, and then it creates the components of the
physics system and passes them into the constructor of the physics world. Bullet
has a wide array of initialization parameters, as you might expect, so all this code is
setting up what components Bullet will use.
One important piece of code in the initialize function turns on a few rendering diag-
nostics by setting up the BulletDebugDrawer , which has the capability of visibly
rendering collision shapes, contact points, and contact normals. Depending on what
your problem is, you might want other things, but this is a good basic set. If you were
really smart, you
d create a little command line debug console in your game and be
able to turn on/off different physics debug information at a whim. That
'
s exactly
what we had for Thief: Deadly Shadows, and it saved our butts on more than one
occasion. You don
'
s too much information.
In fact, you might even want to filter the information for particular objects, which
is something you can do in the debug renderer class you write yourself.
'
t want to draw them all because there
'
Shutdown
Shutting down the physics system is pretty easy. Clean up all of the btRigidBody
objects that you
ve allocated and added to the physics system and then delete the
physics system components.
'
BulletPhysics::~BulletPhysics()
{
// delete any physics objects which are still in the world
// iterate backwards because removing the last object doesn't affect the
// other objects stored in a vector-type array
 
 
Search WWH ::




Custom Search