moisesjpelaez - Physics Improvements

This commit is contained in:
Onek8 2025-06-01 23:52:22 +00:00
parent 6b7460dd4c
commit ed72206a26

View File

@ -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;