Skip to content

Commit

Permalink
Traktor: Calling postUpdate for each simulation tick instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
apistol78 committed Jan 12, 2024
1 parent 5eff631 commit 9b4d664
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions code/Runtime/Impl/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ bool Application::update()

// Measure delta time.
const double deltaTime = m_timer.getDeltaTime();
m_updateInfo.m_frameDeltaTime = lerp(m_updateInfo.m_frameDeltaTime, deltaTime, 0.1);
const double deltaTimeDiff = clamp(deltaTime - m_updateInfo.m_frameDeltaTime, -0.01, 0.01);
m_updateInfo.m_frameDeltaTime = lerp(m_updateInfo.m_frameDeltaTime, m_updateInfo.m_frameDeltaTime + deltaTimeDiff, 0.01);

// Update audio.
if (m_audioServer)
Expand Down Expand Up @@ -684,6 +685,12 @@ bool Application::update()
const double physicsTimeEnd = m_timer.getElapsedTime();
physicsDuration += physicsTimeEnd - physicsTimeStart;

// Post physics update state.
{
T_PROFILER_SCOPE(L"Application post update - State");
currentState->postUpdate(m_stateManager, m_updateInfo);
}

m_updateDuration = physicsTimeEnd - physicsTimeStart + inputTimeEnd - inputTimeStart + updateTimeEnd - updateTimeStart;
m_updateInfo.m_simulationTime += dT;

Expand All @@ -703,13 +710,7 @@ bool Application::update()
break;
}

// Issue post update.
if (updateCount > 0)
{
T_PROFILER_SCOPE(L"Application post update - State");
currentState->postUpdate(m_stateManager, m_updateInfo);
}
else
if (updateCount == 0)
{
m_updateInfo.m_totalTime += dFT;
m_updateInfo.m_stateTime += dFT;
Expand Down

0 comments on commit 9b4d664

Please sign in to comment.