Library/Bullet

Notes on the Bullet physics library...

Per World

 * Create the world with...
 * A BroadPhase object
 * A Dispatcher object
 * A Solver object
 * A CollisonConfiguration

Per Object

 * A Shape (can be shared)
 * A MotionState
 * A RigidBody

...add it to the world

Misc
Do the world transform and motion state position need to be kept in sync?

What's the difference between addRigidBody and addCollisionObject?
The parameter difference is a btRigidBody is passed in rather than a btCollisionObject. The implementation of addRigidBody is essentially a wrapper on a call to btCollisionObject that checks various flags and does additional setup on the rigid body before making the call (e.g. copy gravity parameter from the world to the object, automatically set up filter flags). Call addRigidBody for rigid bodies.

How do I move the player with an FPS-style camera?
There's the "CharacterDemo" in the bullet SDK. This uses the class. However, the lack of documentation on that class and lack of code comments in the demo unfortunately undo a lot of the likely good work that went into setting those up.

Thinking about the problem more fundamentally, the basic algorithm for moving the player looks something like this:

...where is a directed vector whose magnitude equals the speed of the player.

Add in collision detection and it needs to look something like this:

or better:

...where a 'transition' checks if the movement passes through and obstacles.

The above is exactly what a physics simulator like Bullet does; however, it does a lot more than that. Most player characters actually use a non-physical control model which means that accurate physics is not what is desired. Therefore,...

When do I add an impulse versus setting the velocity on an object?
Adding an impulse modifies the current velocity, so in a way, the two are equivalent.

To put is simply, if you 'are' adding an impulse (i.e. a ), then add an impulse. Otherwise the velocity more directly according to what you're simulating.

From btRigidBody.h (Bullet 2.78):

What's the duration / scope of an impulse?
''When I call applyCentralImpulse is that impulse applied once during the next tick of stepSimulation? Or is it applied every tick until something cancels that impulse?''

modifies the rigid body's linear velocity. The impulse is applied "once" since it equivalent to the force applied over a given a period of time.

Make objects more bouncy
Set the restitution property on the RigidBody. Note: the overall bounciness of an impact is affected (obviously) by both objects in the collision.

Wind
See Internal Documentation#Wind.

Reference

 * http://www.sjbaker.org/wiki/index.php?title=Physics_-_Bullet_HelloWorld_example
 * http://www.sjbaker.org/wiki/index.php?title=Physics_-_Bullet_Tutorial2_example