[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / LinearMath / btDefaultMotionState.h
1 #ifndef BT_DEFAULT_MOTION_STATE_H
2 #define BT_DEFAULT_MOTION_STATE_H
3
4 #include "btMotionState.h"
5
6 ///The btDefaultMotionState provides a common implementation to synchronize world transforms with offsets.
7 ATTRIBUTE_ALIGNED16(struct)
8 btDefaultMotionState : public btMotionState
9 {
10         btTransform m_graphicsWorldTrans;
11         btTransform m_centerOfMassOffset;
12         btTransform m_startWorldTrans;
13         void* m_userPointer;
14
15         BT_DECLARE_ALIGNED_ALLOCATOR();
16
17         btDefaultMotionState(const btTransform& startTrans = btTransform::getIdentity(), const btTransform& centerOfMassOffset = btTransform::getIdentity())
18                 : m_graphicsWorldTrans(startTrans),
19                   m_centerOfMassOffset(centerOfMassOffset),
20                   m_startWorldTrans(startTrans),
21                   m_userPointer(0)
22
23         {
24         }
25
26         ///synchronizes world transform from user to physics
27         virtual void getWorldTransform(btTransform & centerOfMassWorldTrans) const
28         {
29                 centerOfMassWorldTrans = m_graphicsWorldTrans * m_centerOfMassOffset.inverse();
30         }
31
32         ///synchronizes world transform from physics to user
33         ///Bullet only calls the update of worldtransform for active objects
34         virtual void setWorldTransform(const btTransform& centerOfMassWorldTrans)
35         {
36                 m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset;
37         }
38 };
39
40 #endif  //BT_DEFAULT_MOTION_STATE_H