mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-25 11:52:40 +01:00
Fixed: accumulated time during pauses, caused terrible framerate
This commit is contained in:
parent
b7d657b9ab
commit
74df3c7e38
@ -423,39 +423,42 @@ int RWGame::run() {
|
|||||||
chrono::duration<float>(currentFrame - lastFrame).count();
|
chrono::duration<float>(currentFrame - lastFrame).count();
|
||||||
lastFrame = currentFrame;
|
lastFrame = currentFrame;
|
||||||
|
|
||||||
// Clamp frameTime, so we won't freeze completely
|
if (!world->isPaused()) {
|
||||||
if (frameTime > 0.1f) {
|
accumulatedTime += frameTime;
|
||||||
frameTime = 0.1f;
|
|
||||||
}
|
|
||||||
|
|
||||||
accumulatedTime += frameTime;
|
// Clamp frameTime, so we won't freeze completely
|
||||||
|
if (frameTime > 0.1f) {
|
||||||
auto deltaTimeWithTimeScale = deltaTime * world->state->basic.timeScale;
|
frameTime = 0.1f;
|
||||||
|
|
||||||
RW_PROFILE_BEGIN("Update");
|
|
||||||
while (accumulatedTime >= deltaTime && !world->isPaused()) {
|
|
||||||
if (!StateManager::currentState()) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RW_PROFILE_BEGIN("physics");
|
auto deltaTimeWithTimeScale =
|
||||||
world->dynamicsWorld->stepSimulation(
|
deltaTime * world->state->basic.timeScale;
|
||||||
deltaTimeWithTimeScale, kMaxPhysicsSubSteps, deltaTime);
|
|
||||||
|
RW_PROFILE_BEGIN("Update");
|
||||||
|
while (accumulatedTime >= deltaTime && !world->isPaused()) {
|
||||||
|
if (!StateManager::currentState()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
RW_PROFILE_BEGIN("physics");
|
||||||
|
world->dynamicsWorld->stepSimulation(
|
||||||
|
deltaTimeWithTimeScale, kMaxPhysicsSubSteps, deltaTime);
|
||||||
|
RW_PROFILE_END();
|
||||||
|
|
||||||
|
RW_PROFILE_BEGIN("state");
|
||||||
|
StateManager::get().tick(deltaTimeWithTimeScale);
|
||||||
|
RW_PROFILE_END();
|
||||||
|
|
||||||
|
RW_PROFILE_BEGIN("engine");
|
||||||
|
tick(deltaTimeWithTimeScale);
|
||||||
|
RW_PROFILE_END();
|
||||||
|
|
||||||
|
getState()->swapInputState();
|
||||||
|
|
||||||
|
accumulatedTime -= deltaTime;
|
||||||
|
}
|
||||||
RW_PROFILE_END();
|
RW_PROFILE_END();
|
||||||
|
|
||||||
RW_PROFILE_BEGIN("state");
|
|
||||||
StateManager::get().tick(deltaTimeWithTimeScale);
|
|
||||||
RW_PROFILE_END();
|
|
||||||
|
|
||||||
RW_PROFILE_BEGIN("engine");
|
|
||||||
tick(deltaTimeWithTimeScale);
|
|
||||||
RW_PROFILE_END();
|
|
||||||
|
|
||||||
getState()->swapInputState();
|
|
||||||
|
|
||||||
accumulatedTime -= deltaTime;
|
|
||||||
}
|
}
|
||||||
RW_PROFILE_END();
|
|
||||||
|
|
||||||
RW_PROFILE_BEGIN("Render");
|
RW_PROFILE_BEGIN("Render");
|
||||||
RW_PROFILE_BEGIN("engine");
|
RW_PROFILE_BEGIN("engine");
|
||||||
|
Loading…
Reference in New Issue
Block a user