I still don't understand why yours is framerate independent and mine isn't. It doesn't seem to matter if I use update() or update(deltaTime).
435 fps - Camera falls very fast, mouse moves camera very slowly (delTatime: 0.002)
104 fps - Camera falls at normal speed, moves moves at normal speed (deltaTime: (delTatime: 0.009)
I know that the timer isn't very precise, but I should still not see that big difference, and there shoud be a difference between using update() and update(deltaTime)?
Code: Select all
ITimer* tmr = device->getTimer();
double lastTime = tmr->getTime();
while(device->run()) {
if (device->isWindowActive()){
//camera control
core::vector3df velocity;
if(up) velocity+=camera_body->getDirectionPositionXY(core::vector3df(0,0,camera_speed));
if(down) velocity+=camera_body->getDirectionPositionXY(core::vector3df(0,0,-camera_speed));
if(left) velocity+=camera_body->getDirectionPositionXY(core::vector3df(-camera_speed,0,0));
if(right) velocity+=camera_body->getDirectionPositionXY(core::vector3df(camera_speed,0,0));
camera_body->setVelocity(velocity);
// start changed code
double time = tmr->getTime();
float deltaTime = (( (float)time - (float)lastTime ) / 1000.0f);
printf("deltaTime %f\n", deltaTime);
lastTime = time;
p_world->update();
// end changed code
driver->beginScene(true, true, 0 );
smgr->drawAll();
if(debug_info)
p_world->drawAllDebugInfos();
driver->endScene();
int fps = driver->getFPS();
if (lastFPS != fps) {
core::stringw str = L"Terrain Renderer - Irrlicht Engine [";
str += driver->getName();
str += "] FPS:";
str += fps;
device->setWindowCaption(str.c_str());
lastFPS = fps;
}
}//is window active
}