I am trying to integrate bullet into my graphics engine and my engine is not thread safe so that it would be unsafe to have any callbacks.
The game logic need to be synchronized with every physical step but without the tick callback.
I want to execute one fixed timestep each call and use a time remainder argument from the user for interpolation from velocity.
Can I use the built in interpolation without modifying the physics engine?
Is there a way to get one fixed step without doing something not officially supported?
Making wrapper without callbacks.
-
- Posts: 49
- Joined: Sun Jan 29, 2012 10:01 pm
Re: Making wrapper without callbacks.
I solved the problem by taking the interpolation code from btDiscreteDynamicsWorld::synchronizeSingleMotionState.
Now I can use the interpolation without motion states as a simple function on top of the rigid body so that it can be used without callbacks.
Now I can use the interpolation without motion states as a simple function on top of the rigid body so that it can be used without callbacks.
Code: Select all
btTransform trans = body->getWorldTransform();
if (body->isStaticOrKinematicObject() || body->getActivationState() == ISLAND_SLEEPING) {
// No interpolation needed
return trans;
} else {
// Use interpolation
btTransform interpolatedTrans;
btTransformUtil::integrateTransform(trans,body->getInterpolationLinearVelocity(),
body->getInterpolationAngularVelocity(),timeOffset*body->getHitFraction(),interpolatedTrans);
return interpolatedTrans;
}