moisesjpelaez - Physics Improvements

This commit is contained in:
2025-06-02 04:18:44 +00:00
parent 26a10020ac
commit 00369aa90b

View File

@ -8,21 +8,23 @@ class Time {
return 1 / frequency; return 1 / frequency;
} }
// TODO: set physics step from Blender's editor static var _fixedStep: Null<Float>;
public static var fixedStep(get, never): Float; public static var fixedStep(get, never): Float;
static function get_fixedStep(): Float { static function get_fixedStep(): Float {
return 1 / 60; return _fixedStep;
} }
public static var scale = 1.0;
public static var delta(get, never): Float; public static function initFixedStep(value: Float = 1 / 60) {
static function get_delta(): Float { _fixedStep = value;
if (frequency == null) initFrequency();
return (1 / frequency) * scale;
} }
static var last = 0.0;
public static var realDelta = 0.0; static var lastTime = 0.0;
public static var delta = 0.0;
static var lastRenderTime = 0.0;
public static var renderDelta = 0.0;
public static inline function time(): Float { public static inline function time(): Float {
return kha.Scheduler.time(); return kha.Scheduler.time();
} }
@ -37,7 +39,12 @@ class Time {
} }
public static function update() { public static function update() {
realDelta = realTime() - last; delta = (realTime() - lastTime) * scale;
last = realTime(); lastTime = realTime();
}
public static function render() {
renderDelta = (realTime() - lastRenderTime) * scale;
lastRenderTime = realTime();
} }
} }