Hi,
I am new to bullet and encounter a seeminly trivial problem. Is it a bug in the btDefaultMotionState or by design?
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 ;
}
In the above, if m_centerOfMassOffset is not the identity, the following assertion will be false
btDefaultMotionState motionState( startTrans, centerOfMassOffset );
btTransform center1;
btTransform center2;
motionState.getWorldTransform( center1 );
motionState.setWorldTransform( center1 );
motionState.getWorldTransform( center2 );
assert( isEqual( center1, center2 ) );
Should setWorldTransform be
m_graphicsWorldTrans = m_centerOfMassOffset * centerOfMassWorldTrans;
instead of
m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset ;
Thanks,
xinguang
set centerOfMassOffset in btDefaultMotionState
-
- Posts: 1
- Joined: Mon Dec 19, 2011 11:16 pm