diff --git a/leenkx/Sources/leenkx/trait/physics/bullet/PhysicsWorld.hx b/leenkx/Sources/leenkx/trait/physics/bullet/PhysicsWorld.hx index bd32508..74dd869 100644 --- a/leenkx/Sources/leenkx/trait/physics/bullet/PhysicsWorld.hx +++ b/leenkx/Sources/leenkx/trait/physics/bullet/PhysicsWorld.hx @@ -101,7 +101,7 @@ class PhysicsWorld extends Trait { - public function new(timeScale = 1.0, maxSteps = 10, solverIterations = 10, debugDrawMode: DebugDrawMode = NoDebug) { + public function new(timeScale = 1.0, maxSteps = 10, solverIterations = 10, fixedStep = 1 / 60, debugDrawMode: DebugDrawMode = NoDebug) { super(); if (nullvec) { @@ -120,6 +120,7 @@ class PhysicsWorld extends Trait { this.timeScale = timeScale; this.maxSteps = maxSteps; this.solverIterations = solverIterations; + Time.initFixedStep(fixedStep); // First scene if (active == null) { @@ -299,7 +300,7 @@ class PhysicsWorld extends Trait { } function fixedUpdate() { - var t = Time.delta * timeScale; + var t = Time.fixedStep * timeScale * Time.scale; if (t == 0.0) return; // Simulation paused #if lnx_debug @@ -308,9 +309,6 @@ class PhysicsWorld extends Trait { if (preUpdates != null) for (f in preUpdates) f(); - //Bullet physics fixed timescale - var fixedTime = 1.0 / 60; - //This condition must be satisfied to not loose time var currMaxSteps = t < (Time.fixedStep * maxSteps) ? maxSteps : 1;