Game Development Reference
// ... Other RigidBody code as before ...
* Holds the amount of damping applied to angular
* motion. Damping is required to remove energy added
* through numerical instability in the integrator.
Just as we saw with linear velocity, the angular velocity is updated with the equa-
θ = θ(d a ) t
+ θ t
where d a is the angular damping coefficient. The complete integration routine now
looks like this:
Excerpt from src/body.cpp
void RigidBody::integrate(real duration)
// Calculate linear acceleration from force inputs.
lastFrameAcceleration = acceleration;
// Calculate angular acceleration from torque inputs.
Vector3 angularAcceleration =
// Adjust velocities
// Update linear velocity from both acceleration and impulse.
// Update angular velocity from both acceleration and impulse.
// Impose drag.
velocity *= real_pow(linearDamping, duration);
rotation *= real_pow(angularDamping, duration);
// Adjust positions
// Update linear position.
// Update angular position.