Torque3D/Engine/lib/bullet/src/LinearMath/btDefaultMotionState.h

43 lines
1.2 KiB
C
Raw Normal View History

2013-07-04 20:50:16 +02:00
#ifndef BT_DEFAULT_MOTION_STATE_H
#define BT_DEFAULT_MOTION_STATE_H
#include "btMotionState.h"
2012-09-19 11:15:01 -04:00
///The btDefaultMotionState provides a common implementation to synchronize world transforms with offsets.
ATTRIBUTE_ALIGNED16(struct) btDefaultMotionState : public btMotionState
2012-09-19 11:15:01 -04:00
{
btTransform m_graphicsWorldTrans;
btTransform m_centerOfMassOffset;
2012-09-19 11:15:01 -04:00
btTransform m_startWorldTrans;
void* m_userPointer;
2012-09-19 11:15:01 -04:00
2013-07-04 20:50:16 +02:00
BT_DECLARE_ALIGNED_ALLOCATOR();
btDefaultMotionState(const btTransform& startTrans = btTransform::getIdentity(),const btTransform& centerOfMassOffset = btTransform::getIdentity())
2012-09-19 11:15:01 -04:00
: m_graphicsWorldTrans(startTrans),
m_centerOfMassOffset(centerOfMassOffset),
m_startWorldTrans(startTrans),
m_userPointer(0)
2012-09-19 11:15:01 -04:00
{
}
///synchronizes world transform from user to physics
virtual void getWorldTransform(btTransform& centerOfMassWorldTrans ) const
2012-09-19 11:15:01 -04:00
{
centerOfMassWorldTrans = m_graphicsWorldTrans * m_centerOfMassOffset.inverse() ;
2012-09-19 11:15:01 -04:00
}
///synchronizes world transform from physics to user
///Bullet only calls the update of worldtransform for active objects
virtual void setWorldTransform(const btTransform& centerOfMassWorldTrans)
2012-09-19 11:15:01 -04:00
{
m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset;
2012-09-19 11:15:01 -04:00
}
2012-09-19 11:15:01 -04:00
};
#endif //BT_DEFAULT_MOTION_STATE_H