From 0338a0683689318717b45d63b13f1b16107de19a Mon Sep 17 00:00:00 2001 From: ViktorLjung Date: Wed, 16 Apr 2014 14:38:26 +0200 Subject: [PATCH] Fixed timestep. --- src/Systems/PhysicsSystem.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Systems/PhysicsSystem.cpp b/src/Systems/PhysicsSystem.cpp index 1e423c3..98ee002 100644 --- a/src/Systems/PhysicsSystem.cpp +++ b/src/Systems/PhysicsSystem.cpp @@ -68,7 +68,13 @@ void Systems::PhysicsSystem::RegisterComponents(ComponentFactory* cf) void Systems::PhysicsSystem::Update(double dt) { - m_PhysicsWorld->stepDeltaTime(0.0166f); + static const double timestep = 1 / 60.0; + m_Accumulator += dt; + while (m_Accumulator >= timestep) + { + m_PhysicsWorld->stepDeltaTime(timestep); + m_Accumulator -= timestep; + } // Step the visual debugger StepVisualDebugger();