Magnum::BulletIntegration::MotionState class

Bullet Physics motion state.

Encapsulates btMotionState as a SceneGraph feature.

Usage

Common usage is to either create a btRigidBody to share transformation with a SceneGraph::Object by passing the motion state in its constructor:

btDynamicsWorld* btWorld;
SceneGraph::Object<SceneGraph::MatrixTransformation3D> object;

auto motionState = new BulletIntegration::MotionState{object};
auto collisionShape = new btBoxShape{{0.5f, 0.5f, 0.5f}};
auto rigidBody = new btRigidBody{20.0f, &motionState->btMotionState(), collisionShape};
btWorld->addRigidBody(rigidBody);

This way, the rigidBody will be affected when transformation of the object is changed from the scenegraph and also the other way around — the object gets its position updated when the Bullet world changes. It's also possible to attach the motion state afterwards:

rigidBody->setMotionState(&motionState->btMotionState());

Note that changes to a rigidBody using btRigidBody::setWorldTransform() may only update the motion state of non-static objects and while btDynamicsWorld::stepSimulation() is called.

Base classes

template<UnsignedInt dimensions, class T>
class Magnum::SceneGraph::AbstractFeature
Base for object features.

Constructors, destructors, conversion operators

template<class T>
MotionState(T& object)
Constructor.

Public functions

auto btMotionState() -> btMotionState&
Motion state.

Function documentation

template<class T>
Magnum::BulletIntegration::MotionState::MotionState(T& object)

Constructor.

Parameters
object Object this motion state belongs to