This commit is contained in:
Benau 2020-08-31 08:46:02 +08:00
parent 09319c6c73
commit 13fa56d951
2 changed files with 17 additions and 0 deletions

View File

@ -552,6 +552,7 @@ extern "C" void handle_joystick(SDL_Event& event);
// In main_loop.cpp
extern "C" void pause_mainloop();
extern "C" void resume_mainloop();
extern "C" void reset_network_body();
//! runs the device. Returns false if device wants to be deleted
bool CIrrDeviceSDL::run()
{
@ -770,6 +771,7 @@ bool CIrrDeviceSDL::run()
Height = new_height;
if (VideoDriver)
VideoDriver->OnResize(core::dimension2d<u32>(Width, Height));
reset_network_body();
}
else if (SDL_event.window.event == SDL_WINDOWEVENT_MINIMIZED)
{
@ -782,11 +784,17 @@ bool CIrrDeviceSDL::run()
else if (SDL_event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
{
WindowHasFocus = true;
reset_network_body();
}
else if (SDL_event.window.event == SDL_WINDOWEVENT_FOCUS_LOST)
{
WindowHasFocus = false;
}
else if (SDL_event.window.event == SDL_WINDOWEVENT_MOVED)
{
// In windows the rendering is paused when window is moving
reset_network_body();
}
}
break;
case SDL_TEXTEDITING:

View File

@ -150,6 +150,15 @@ extern "C" void resume_mainloop()
} // resume_mainloop
#endif
//-----------------------------------------------------------------------------
extern "C" void reset_network_body()
{
// In windows the rendering is paused when out focus, which pauses the
// smooth timer
if (World::getWorld() && RewindManager::isEnabled())
RewindManager::get()->resetSmoothNetworkBody();
} // reset_network_body
//-----------------------------------------------------------------------------
/** Returns the current dt, which guarantees a limited frame rate. If dt is
* too low (the frame rate too high), the process will sleep to reach the