Game Development Reference
In-Depth Information
For more information about any of these classes, consult the Bullet documentation or,
better yet, read the Bullet source code and examples. Open source is great that way!
Let
s take a look at the implementation of the
IGamePhysics
interface,
Bullet-
Physics
. The
init
function for this implementation class runs through the follow-
ing tasks:
'
n
Initializes the
btDynamicsWorld
and components
members.
n
Creates the internal tick callback, which is used to send collision events.
n
Sets debug rendering parameters.
'
bool BulletPhysics::VInitialize()
{
LoadXml();
// this controls how Bullet does internal memory management
m_collisionConfiguration = GCC_NEW( btDefaultCollisionConfiguration();
// manages how Bullet detects precise collisions between objects
m_dispatcher =
GCC_NEW btCollisionDispatcher( m_collisionConfiguration.get() );
// Bullet uses this to quickly (imprecisely) detect collisions between
// objects. Once a possible collision passes the broad phase, it will be
// passed to the slower but more precise narrow-phase collision detection
// (btCollisionDispatcher).
m_broadphase = GCC_NEW btDbvtBroadphase();
// Manages constraints which apply forces to the physics simulation.
// Used for e.g. springs, motors. We don
'
t use any constraints right
// now.
m_solver = GCC_NEW btSequentialImpulseConstraintSolver;
// This is the main Bullet interface point. Pass in all these components
// to customize its behavior.
m_dynamicsWorld = GCC_NEW
btDiscreteDynamicsWorld( m_dispatcher, m_broadphase, m_solver,
m_collisionConfiguration );
// also set up the functionality for debug drawing
m_debugDrawer = GCC_NEW BulletDebugDrawer;
if(!m_collisionConfiguration
jj
!m_dispatcher
jj
!m_broadphase
jj
!m_solver
jj
!m_dynamicsWorld
jj
!m_debugDrawer)