added synchronizeSingleMotionState, thanks Chunky.
This commit is contained in:
@@ -250,6 +250,25 @@ void btDiscreteDynamicsWorld::applyGravity()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void btDiscreteDynamicsWorld::synchronizeSingleMotionState(btRigidBody* body)
|
||||||
|
{
|
||||||
|
btAssert(body);
|
||||||
|
|
||||||
|
if (body->getMotionState() && !body->isStaticOrKinematicObject())
|
||||||
|
{
|
||||||
|
//we need to call the update at least once, even for sleeping objects
|
||||||
|
//otherwise the 'graphics' transform never updates properly
|
||||||
|
///@todo: add 'dirty' flag
|
||||||
|
//if (body->getActivationState() != ISLAND_SLEEPING)
|
||||||
|
{
|
||||||
|
btTransform interpolatedTransform;
|
||||||
|
btTransformUtil::integrateTransform(body->getInterpolationWorldTransform(),
|
||||||
|
body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),m_localTime*body->getHitFraction(),interpolatedTransform);
|
||||||
|
body->getMotionState()->setWorldTransform(interpolatedTransform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void btDiscreteDynamicsWorld::synchronizeMotionStates()
|
void btDiscreteDynamicsWorld::synchronizeMotionStates()
|
||||||
{
|
{
|
||||||
@@ -261,19 +280,8 @@ void btDiscreteDynamicsWorld::synchronizeMotionStates()
|
|||||||
btCollisionObject* colObj = m_activeObjects[i];
|
btCollisionObject* colObj = m_activeObjects[i];
|
||||||
|
|
||||||
btRigidBody* body = btRigidBody::upcast(colObj);
|
btRigidBody* body = btRigidBody::upcast(colObj);
|
||||||
if (body && body->getMotionState() && !body->isStaticOrKinematicObject())
|
if (body)
|
||||||
{
|
synchronizeSingleMotionState(body);
|
||||||
//we need to call the update at least once, even for sleeping objects
|
|
||||||
//otherwise the 'graphics' transform never updates properly
|
|
||||||
///@todo: add 'dirty' flag
|
|
||||||
//if (body->getActivationState() != ISLAND_SLEEPING)
|
|
||||||
{
|
|
||||||
btTransform interpolatedTransform;
|
|
||||||
btTransformUtil::integrateTransform(body->getInterpolationWorldTransform(),
|
|
||||||
body->getInterpolationLinearVelocity(),body->getInterpolationAngularVelocity(),m_localTime*body->getHitFraction(),interpolatedTransform);
|
|
||||||
body->getMotionState()->setWorldTransform(interpolatedTransform);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ public:
|
|||||||
|
|
||||||
virtual void synchronizeMotionStates();
|
virtual void synchronizeMotionStates();
|
||||||
|
|
||||||
|
///this can be useful to synchronize a single rigid body -> graphics object
|
||||||
|
void synchronizeSingleMotionState(btRigidBody* body);
|
||||||
|
|
||||||
void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
|
void addConstraint(btTypedConstraint* constraint, bool disableCollisionsBetweenLinkedBodies=false);
|
||||||
|
|
||||||
void removeConstraint(btTypedConstraint* constraint);
|
void removeConstraint(btTypedConstraint* constraint);
|
||||||
|
|||||||
Reference in New Issue
Block a user