mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 10:23:56 +00:00
Limit maximum frame time to 200ms
This effectively slows game time when it drops below 5 fps. Something like this is desirable when dealing with time-based animations, which can jump forward after a lengthy cell transition.
This commit is contained in:
parent
d208422ca7
commit
df8889dcc4
1 changed files with 9 additions and 8 deletions
|
@ -67,14 +67,15 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
{
|
||||
try
|
||||
{
|
||||
mEnvironment.setFrameDuration (evt.timeSinceLastFrame);
|
||||
float frametime = std::min(evt.timeSinceLastFrame, 0.2f);
|
||||
mEnvironment.setFrameDuration(frametime);
|
||||
|
||||
// update input
|
||||
MWBase::Environment::get().getInputManager()->update(evt.timeSinceLastFrame, false);
|
||||
MWBase::Environment::get().getInputManager()->update(frametime, false);
|
||||
|
||||
// sound
|
||||
if (mUseSound)
|
||||
MWBase::Environment::get().getSoundManager()->update (evt.timeSinceLastFrame);
|
||||
MWBase::Environment::get().getSoundManager()->update(frametime);
|
||||
|
||||
// global scripts
|
||||
MWBase::Environment::get().getScriptManager()->getGlobalScripts().run();
|
||||
|
@ -88,19 +89,19 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
|
||||
// passing of time
|
||||
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||
MWBase::Environment::get().getWorld()->advanceTime (
|
||||
mEnvironment.getFrameDuration()*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
|
||||
MWBase::Environment::get().getWorld()->advanceTime(
|
||||
frametime*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
|
||||
|
||||
|
||||
if (changed) // keep change flag for another frame, if cell changed happend in local script
|
||||
MWBase::Environment::get().getWorld()->markCellAsUnchanged();
|
||||
|
||||
// update actors
|
||||
MWBase::Environment::get().getMechanicsManager()->update(mEnvironment.getFrameDuration(),
|
||||
MWBase::Environment::get().getMechanicsManager()->update(frametime,
|
||||
MWBase::Environment::get().getWindowManager()->isGuiMode());
|
||||
|
||||
// update world
|
||||
MWBase::Environment::get().getWorld()->update (evt.timeSinceLastFrame, MWBase::Environment::get().getWindowManager()->isGuiMode());
|
||||
MWBase::Environment::get().getWorld()->update(frametime, MWBase::Environment::get().getWindowManager()->isGuiMode());
|
||||
|
||||
// update GUI
|
||||
Ogre::RenderWindow* window = mOgre->getWindow();
|
||||
|
@ -108,7 +109,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
MWBase::Environment::get().getWorld()->getTriangleBatchCount(tri, batch);
|
||||
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), tri, batch);
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->onFrame(evt.timeSinceLastFrame);
|
||||
MWBase::Environment::get().getWindowManager()->onFrame(frametime);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue