@ -108,12 +108,14 @@ void OMW::Engine::executeLocalScripts()
}
}
}
}
void OMW : : Engine : : frame ( float frametime )
bool OMW : : Engine : : frame ( float frametime )
{
{
try
try
{
{
mStartTick = mViewer - > getStartTick ( ) ;
mStartTick = mViewer - > getStartTick ( ) ;
mEnvironment . setFrameDuration ( frametime ) ;
// update input
// update input
mEnvironment . getInputManager ( ) - > update ( frametime , false ) ;
mEnvironment . getInputManager ( ) - > update ( frametime , false ) ;
@ -121,7 +123,7 @@ void OMW::Engine::frame(float frametime)
// If we are not currently rendering, then RenderItems will not be reused resulting in a memory leak upon changing widget textures (fixed in MyGUI 3.3.2),
// If we are not currently rendering, then RenderItems will not be reused resulting in a memory leak upon changing widget textures (fixed in MyGUI 3.3.2),
// and destroyed widgets will not be deleted (not fixed yet, https://github.com/MyGUI/mygui/issues/21)
// and destroyed widgets will not be deleted (not fixed yet, https://github.com/MyGUI/mygui/issues/21)
if ( ! mEnvironment . getInputManager ( ) - > isWindowVisible ( ) )
if ( ! mEnvironment . getInputManager ( ) - > isWindowVisible ( ) )
return ;
return false ;
// sound
// sound
if ( mUseSound )
if ( mUseSound )
@ -257,8 +259,9 @@ void OMW::Engine::frame(float frametime)
}
}
catch ( const std : : exception & e )
catch ( const std : : exception & e )
{
{
std : : cerr < < " Error in frame listener : " < < e . what ( ) < < std : : endl ;
std : : cerr < < " Error in frame : " < < e . what ( ) < < std : : endl ;
}
}
return true ;
}
}
OMW : : Engine : : Engine ( Files : : ConfigurationManager & configurationManager )
OMW : : Engine : : Engine ( Files : : ConfigurationManager & configurationManager )
@ -817,6 +820,22 @@ void OMW::Engine::go()
frameTimer . setStartTick ( ) ;
frameTimer . setStartTick ( ) ;
dt = std : : min ( dt , 0.2 ) ;
dt = std : : min ( dt , 0.2 ) ;
mViewer - > advance ( simulationTime ) ;
if ( ! frame ( dt ) )
{
OpenThreads : : Thread : : microSleep ( 5000 ) ;
continue ;
}
else
{
mViewer - > eventTraversal ( ) ;
mViewer - > updateTraversal ( ) ;
mEnvironment . getWorld ( ) - > updateWindowManager ( ) ;
mViewer - > renderingTraversals ( ) ;
bool guiActive = mEnvironment . getWindowManager ( ) - > isGuiMode ( ) ;
bool guiActive = mEnvironment . getWindowManager ( ) - > isGuiMode ( ) ;
/*
/*
@ -832,26 +851,6 @@ void OMW::Engine::go()
if ( ! guiActive )
if ( ! guiActive )
simulationTime + = dt ;
simulationTime + = dt ;
mViewer - > advance ( simulationTime ) ;
mEnvironment . setFrameDuration ( dt ) ;
frame ( dt ) ;
if ( ! mEnvironment . getInputManager ( ) - > isWindowVisible ( ) )
{
OpenThreads : : Thread : : microSleep ( 5000 ) ;
continue ;
}
else
{
mViewer - > eventTraversal ( ) ;
mViewer - > updateTraversal ( ) ;
mEnvironment . getWorld ( ) - > updateWindowManager ( ) ;
mViewer - > renderingTraversals ( ) ;
}
}
mEnvironment . limitFrameRate ( frameTimer . time_s ( ) ) ;
mEnvironment . limitFrameRate ( frameTimer . time_s ( ) ) ;