1 #ifndef BT_DEFAULT_MOTION_STATE_H
2 #define BT_DEFAULT_MOTION_STATE_H
4 #include "btMotionState.h"
6 ///The btDefaultMotionState provides a common implementation to synchronize world transforms with offsets.
7 ATTRIBUTE_ALIGNED16(struct) btDefaultMotionState : public btMotionState
9 btTransform m_graphicsWorldTrans;
10 btTransform m_centerOfMassOffset;
11 btTransform m_startWorldTrans;
14 BT_DECLARE_ALIGNED_ALLOCATOR();
16 btDefaultMotionState(const btTransform& startTrans = btTransform::getIdentity(),const btTransform& centerOfMassOffset = btTransform::getIdentity())
17 : m_graphicsWorldTrans(startTrans),
18 m_centerOfMassOffset(centerOfMassOffset),
19 m_startWorldTrans(startTrans),
25 ///synchronizes world transform from user to physics
26 virtual void getWorldTransform(btTransform& centerOfMassWorldTrans ) const
28 centerOfMassWorldTrans = m_centerOfMassOffset.inverse() * m_graphicsWorldTrans ;
31 ///synchronizes world transform from physics to user
32 ///Bullet only calls the update of worldtransform for active objects
33 virtual void setWorldTransform(const btTransform& centerOfMassWorldTrans)
35 m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset ;
42 #endif //BT_DEFAULT_MOTION_STATE_H