forked from teamnwah/openmw-tes3coop
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
|
try
|
||||||
{
|
{
|
||||||
mEnvironment.setFrameDuration (evt.timeSinceLastFrame);
|
float frametime = std::min(evt.timeSinceLastFrame, 0.2f);
|
||||||
|
mEnvironment.setFrameDuration(frametime);
|
||||||
|
|
||||||
// update input
|
// update input
|
||||||
MWBase::Environment::get().getInputManager()->update(evt.timeSinceLastFrame, false);
|
MWBase::Environment::get().getInputManager()->update(frametime, false);
|
||||||
|
|
||||||
// sound
|
// sound
|
||||||
if (mUseSound)
|
if (mUseSound)
|
||||||
MWBase::Environment::get().getSoundManager()->update (evt.timeSinceLastFrame);
|
MWBase::Environment::get().getSoundManager()->update(frametime);
|
||||||
|
|
||||||
// global scripts
|
// global scripts
|
||||||
MWBase::Environment::get().getScriptManager()->getGlobalScripts().run();
|
MWBase::Environment::get().getScriptManager()->getGlobalScripts().run();
|
||||||
|
@ -88,19 +89,19 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
||||||
|
|
||||||
// passing of time
|
// passing of time
|
||||||
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
if (!MWBase::Environment::get().getWindowManager()->isGuiMode())
|
||||||
MWBase::Environment::get().getWorld()->advanceTime (
|
MWBase::Environment::get().getWorld()->advanceTime(
|
||||||
mEnvironment.getFrameDuration()*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
|
frametime*MWBase::Environment::get().getWorld()->getTimeScaleFactor()/3600);
|
||||||
|
|
||||||
|
|
||||||
if (changed) // keep change flag for another frame, if cell changed happend in local script
|
if (changed) // keep change flag for another frame, if cell changed happend in local script
|
||||||
MWBase::Environment::get().getWorld()->markCellAsUnchanged();
|
MWBase::Environment::get().getWorld()->markCellAsUnchanged();
|
||||||
|
|
||||||
// update actors
|
// update actors
|
||||||
MWBase::Environment::get().getMechanicsManager()->update(mEnvironment.getFrameDuration(),
|
MWBase::Environment::get().getMechanicsManager()->update(frametime,
|
||||||
MWBase::Environment::get().getWindowManager()->isGuiMode());
|
MWBase::Environment::get().getWindowManager()->isGuiMode());
|
||||||
|
|
||||||
// update world
|
// 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
|
// update GUI
|
||||||
Ogre::RenderWindow* window = mOgre->getWindow();
|
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().getWorld()->getTriangleBatchCount(tri, batch);
|
||||||
MWBase::Environment::get().getWindowManager()->wmUpdateFps(window->getLastFPS(), 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)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue