From cfbe7c83cb52f1cbdffa97d0abd62c072d193692 Mon Sep 17 00:00:00 2001 From: Onek8 Date: Sun, 1 Jun 2025 23:09:47 +0000 Subject: [PATCH] moisesjpelaez - Add fixedUpdate for Physics --- .../leenkx/trait/physics/bullet/PhysicsWorld.hx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/leenkx/Sources/leenkx/trait/physics/bullet/PhysicsWorld.hx b/leenkx/Sources/leenkx/trait/physics/bullet/PhysicsWorld.hx index e2bea17..bd32508 100644 --- a/leenkx/Sources/leenkx/trait/physics/bullet/PhysicsWorld.hx +++ b/leenkx/Sources/leenkx/trait/physics/bullet/PhysicsWorld.hx @@ -136,10 +136,10 @@ class PhysicsWorld extends Trait { conMap = new Map(); active = this; - // Ensure physics are updated first in the lateUpdate list - _lateUpdate = [lateUpdate]; - @:privateAccess iron.App.traitLateUpdates.insert(0, lateUpdate); - + // Ensure physics are updated first in the fixedUpdate list + _fixedUpdate = [fixedUpdate]; + @:privateAccess iron.App.traitFixedUpdates.insert(0, fixedUpdate); + setDebugDrawMode(debugDrawMode); iron.Scene.active.notifyOnRemove(function() { @@ -298,7 +298,7 @@ class PhysicsWorld extends Trait { return rb; } - function lateUpdate() { + function fixedUpdate() { var t = Time.delta * timeScale; if (t == 0.0) return; // Simulation paused @@ -312,9 +312,9 @@ class PhysicsWorld extends Trait { var fixedTime = 1.0 / 60; //This condition must be satisfied to not loose time - var currMaxSteps = t < (fixedTime * maxSteps) ? maxSteps : 1; + var currMaxSteps = t < (Time.fixedStep * maxSteps) ? maxSteps : 1; - world.stepSimulation(t, currMaxSteps, fixedTime); + world.stepSimulation(t, currMaxSteps, Time.fixedStep); updateContacts(); for (rb in rbMap) @:privateAccess rb.physicsUpdate();