http://www.blender.org/forum/viewtopic. ... 2558#42558
My problem is that i have a dynamic platform that i controll using the keyboard to inclinate it. On this platform there is an object spinning around. When i set the new position of the platform, sometimes it penetrates the object, and makes it jump high, or even fall through.
I'm not sure of the right way to do this, i've implemented myself the following code:
Code: Select all
void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
{
// added by bandoler. don't trust this
SimdTransform xform = m_body->getCenterOfMassTransform();
xform.setRotation( SimdQuaternion(quatImag0,quatImag1,quatImag2,quatReal) );
this->m_body->setCenterOfMassTransform(xform);
}
void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
{
// added by bandoler. don't trust this
SimdTransform xform = m_body->getCenterOfMassTransform();
xform.setOrigin( SimdVector3(posX,posY,posZ) );
this->m_body->setCenterOfMassTransform(xform);
}
Also, i'm calling the update on the physics engine once per frame, and i suppose this has to be more complex than this... My main loop looks like:
Code: Select all
while (!lExit)
{
double lCurrentTime = PIL_check_seconds_timer();
double lDeltaTime = lCurrentTime - lLastTime;
lLastTime = lCurrentTime;
// Process events
lExit = lEngine->ProcessEvents();
// Process logic pipelines
for ( unsigned int i=0;i<lLogicPipelines.size(); i++ )
lLogicPipelines[i]->Run();
// Run the physics
lEngine->iPhysicsEnvironment->beginFrame();
lEngine->iPhysicsEnvironment->proceedDeltaTime( lCurrentTime, lDeltaTime );
lEngine->iPhysicsEnvironment->endFrame();
// Run the graphics pipeline
get_render_pipeline()->Run();
}
(bandoler)