2017-08-01 12:30:58 +00:00
|
|
|
#ifndef BT_DEFAULT_MOTION_STATE_H
|
|
|
|
#define BT_DEFAULT_MOTION_STATE_H
|
|
|
|
|
|
|
|
#include "btMotionState.h"
|
|
|
|
|
|
|
|
///The btDefaultMotionState provides a common implementation to synchronize world transforms with offsets.
|
2019-01-03 13:26:51 +00:00
|
|
|
ATTRIBUTE_ALIGNED16(struct)
|
|
|
|
btDefaultMotionState : public btMotionState
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
|
|
|
btTransform m_graphicsWorldTrans;
|
2019-01-03 13:26:51 +00:00
|
|
|
btTransform m_centerOfMassOffset;
|
2017-08-01 12:30:58 +00:00
|
|
|
btTransform m_startWorldTrans;
|
2019-01-03 13:26:51 +00:00
|
|
|
void* m_userPointer;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
BT_DECLARE_ALIGNED_ALLOCATOR();
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
btDefaultMotionState(const btTransform& startTrans = btTransform::getIdentity(), const btTransform& centerOfMassOffset = btTransform::getIdentity())
|
2017-08-01 12:30:58 +00:00
|
|
|
: m_graphicsWorldTrans(startTrans),
|
2019-01-03 13:26:51 +00:00
|
|
|
m_centerOfMassOffset(centerOfMassOffset),
|
|
|
|
m_startWorldTrans(startTrans),
|
|
|
|
m_userPointer(0)
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
///synchronizes world transform from user to physics
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual void getWorldTransform(btTransform & centerOfMassWorldTrans) const
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
centerOfMassWorldTrans = m_graphicsWorldTrans * m_centerOfMassOffset.inverse();
|
2017-08-01 12:30:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///synchronizes world transform from physics to user
|
|
|
|
///Bullet only calls the update of worldtransform for active objects
|
2019-01-03 13:26:51 +00:00
|
|
|
virtual void setWorldTransform(const btTransform& centerOfMassWorldTrans)
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset;
|
2017-08-01 12:30:58 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
#endif //BT_DEFAULT_MOTION_STATE_H
|