Skip to content

Commit bf12d49

Browse files
committed
fix: fixed update accumulator
1 parent 9be00d3 commit bf12d49

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ if (FREYR_PROFILING)
2727
add_subdirectory(vendor/perfetto)
2828
endif (FREYR_PROFILING)
2929

30-
project(freyr LANGUAGES C CXX VERSION 0.20.8)
30+
project(freyr LANGUAGES C CXX VERSION 0.20.9)
3131

3232
if (FREYR_BUILD_EXAMPLES)
3333
add_subdirectory(examples)

src/Core/Scene.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,11 @@ namespace FREYR_NAMESPACE
120120
const auto provider = mServiceProvider.lock()->CreateServiceScope()->GetServiceProvider();
121121

122122
mFixedDeltaTimeAccumulator += deltaTime;
123+
constexpr int maxSteps = 3;
124+
int steps = 0;
123125

124-
while (mFixedDeltaTimeAccumulator >= mOptions->FixedDeltaTime)
126+
while (mFixedDeltaTimeAccumulator >= mOptions->FixedDeltaTime && steps < maxSteps)
125127
{
126-
mFixedDeltaTimeAccumulator =
127-
std::min(mOptions->FixedDeltaTime, mFixedDeltaTimeAccumulator - mOptions->FixedDeltaTime);
128-
129128
FREYR_PROFILING_BEGIN("FREYR", "PreFixedUpdate", perfetto::Track(0));
130129
mTaskManager->StartWorkers();
131130
mSystemManager->PreFixedUpdate(mOptions->FixedDeltaTime, provider);
@@ -146,6 +145,14 @@ namespace FREYR_NAMESPACE
146145
mTaskManager->WaitForAllTasks();
147146
DestroyEntities();
148147
FREYR_PROFILING_END("FREYR", perfetto::Track(0));
148+
149+
mFixedDeltaTimeAccumulator -= mOptions->FixedDeltaTime;
150+
steps++;
151+
}
152+
153+
if (steps >= maxSteps)
154+
{
155+
mFixedDeltaTimeAccumulator = 0.0f;
149156
}
150157

151158
FREYR_PROFILING_BEGIN("FREYR", "PreUpdate", perfetto::Track(0), "TotalEntities",

0 commit comments

Comments
 (0)