MaxDZ8 wrote:
Last time I used GetTickCount it had a 20ms granularity. I'm not aware of how it works now on your system. That was insufficient to handle 300fps, let alone 1000. What's the granularity on your system?
Hmm, thanks for pointing that out. I didn't even bother trying to figure out the granularity because either way using GetTickCount() would be useless at this point because it lack accuracy. I switched over to timeGetTime(), but now the simulation of the ragdoll seems very slow. This is my main render function now:
Code:
processWindowMsg();
if (timeGetTime()-frameEndTime < ((FPS_LIMIT)*0.001))
return;
frameStartTime = timeGetTime();
physics.update(frameTime);
cam->process(d3ddev);
d3ddev->ClearRenderTargetView(renderTargetView, D3DXVECTOR4(0, 0, 0, 1));
d3ddev->ClearDepthStencilView(DepthStencilView, D3D10_CLEAR_DEPTH|D3D10_CLEAR_STENCIL, 1.0f, 0);
view->SetMatrix((float*)&(cam->matView));
projection->SetMatrix((float*)&(cam->matProjection));
D3DXVECTOR3 c = D3DXVECTOR3(cam->getPos());
cameraPos->SetFloatVector((float*)&c);
ModelList::iterator it;
for (it=_mdlList.begin();it!=_mdlList.end();it++)
{
if ((*it).second[0].model.hasMotionStarted())
{
(*it).second[0].model.updateMotion();
}
if ((*it).second[0].visible)
{
renderingSkel->SetBool(false);
(*it).second[0].model.render();
}
frameEndTime = timeGetTime();
frameTime = frameEndTime-frameStartTime;
and the physics.update function:
Code:
if (deltaTime == 0)
return;
sec = btScalar(deltaTime*0.001);/* convert frame to second */
float fps = 1.0f/sec;
_world->stepSimulation(sec, (int)fps, sec);
I still have no idea about how to correctly use the stepSimulation function for a realistic ragdoll simulation though, and the Stepping The World wiki entry didn't seem to explain things to make it any easier to understand.