moisesjpelaez - Physics Improvements

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

View File

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