diff options
Diffstat (limited to 'extern/bullet2/LinearMath/btDefaultMotionState.h')
-rw-r--r-- | extern/bullet2/LinearMath/btDefaultMotionState.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/extern/bullet2/LinearMath/btDefaultMotionState.h b/extern/bullet2/LinearMath/btDefaultMotionState.h new file mode 100644 index 00000000000..7858a10d219 --- /dev/null +++ b/extern/bullet2/LinearMath/btDefaultMotionState.h @@ -0,0 +1,40 @@ +#ifndef DEFAULT_MOTION_STATE_H +#define DEFAULT_MOTION_STATE_H + +#include "btMotionState.h" + +///The btDefaultMotionState provides a common implementation to synchronize world transforms with offsets. +struct btDefaultMotionState : public btMotionState +{ + btTransform m_graphicsWorldTrans; + btTransform m_centerOfMassOffset; + btTransform m_startWorldTrans; + void* m_userPointer; + + btDefaultMotionState(const btTransform& startTrans = btTransform::getIdentity(),const btTransform& centerOfMassOffset = btTransform::getIdentity()) + : m_graphicsWorldTrans(startTrans), + m_centerOfMassOffset(centerOfMassOffset), + m_startWorldTrans(startTrans), + m_userPointer(0) + + { + } + + ///synchronizes world transform from user to physics + virtual void getWorldTransform(btTransform& centerOfMassWorldTrans ) const + { + centerOfMassWorldTrans = m_centerOfMassOffset.inverse() * m_graphicsWorldTrans ; + } + + ///synchronizes world transform from physics to user + ///Bullet only calls the update of worldtransform for active objects + virtual void setWorldTransform(const btTransform& centerOfMassWorldTrans) + { + m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset ; + } + + + +}; + +#endif //DEFAULT_MOTION_STATE_H |