Code: Select all
btTransform temp;
motionstate.getWorldTransform( temp );
motionstate.setWorldTransform( temp );
as it is currently in the svn repository, the code above results in motionstate having the following internal state:
m_graphicsWorldTrans = m_centerOfMassOffset.inverse() * m_graphicsWorldTrans * m_centerOfMassOffset;
this is NOT the same initial state of the system.
my patch changes it to reduce to:
m_graphicsWorldTrans = m_graphicsWorldTrans * m_centerOfMassOffset.inverse() * m_centerOfMassOffset;
which results in the correct reduction to:
m_graphicsWorldTrans = m_graphicsWorldTrans;
Code: Select all
Index: src/LinearMath/btDefaultMotionState.h
===================================================================
--- src/LinearMath/btDefaultMotionState.h (revision 2116)
+++ src/LinearMath/btDefaultMotionState.h (working copy)
@@ -21,20 +21,18 @@
}
///synchronizes world transform from user to physics
- virtual void getWorldTransform(btTransform& centerOfMassWorldTrans ) const
+ virtual void getWorldTransform(btTransform& centerOfMassWorldTrans ) const
{
- centerOfMassWorldTrans = m_centerOfMassOffset.inverse() * m_graphicsWorldTrans ;
+ centerOfMassWorldTrans = m_graphicsWorldTrans * m_centerOfMassOffset.inverse();
}
///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 ;
+ m_graphicsWorldTrans = centerOfMassWorldTrans * m_centerOfMassOffset;
}
-
-
};