forked from LeenkxTeam/LNXSDK
Repe [T3DU] and Moises Jpelaez updates
This commit is contained in:
@ -2,27 +2,19 @@ package iron.system;
|
||||
|
||||
class Time {
|
||||
public static var scale = 1.0;
|
||||
|
||||
// TODO: VR Frame Time Override - used to sync physics with VR headset refresh rate
|
||||
#if lnx_vr
|
||||
public static var vrFrameTime: Float = -1.0; // VR frame time in seconds (-1 = not in VR)
|
||||
static var lastVRFrameTime: Float = 0.0;
|
||||
static var vrFrameCount: Int = 0;
|
||||
static var normalModeLogged: Bool = false;
|
||||
#end
|
||||
|
||||
|
||||
static var frequency: Null<Int> = null;
|
||||
static function initFrequency() {
|
||||
frequency = kha.Display.primary != null ? kha.Display.primary.frequency : 60;
|
||||
}
|
||||
|
||||
|
||||
public static var step(get, never): Float;
|
||||
static function get_step(): Float {
|
||||
if (frequency == null) initFrequency();
|
||||
return 1 / frequency;
|
||||
}
|
||||
|
||||
static var _fixedStep: Null<Float> = 1/60;
|
||||
|
||||
static var _fixedStep: Null<Float> = 1 / 60;
|
||||
public static var fixedStep(get, never): Float;
|
||||
static function get_fixedStep(): Float {
|
||||
return _fixedStep;
|
||||
@ -32,31 +24,45 @@ class Time {
|
||||
_fixedStep = value;
|
||||
}
|
||||
|
||||
static var _fixedStepInterpolation: Float = 0.0;
|
||||
public static var fixedStepInterpolation(get, never): Float;
|
||||
static function get_fixedStepInterpolation(): Float {
|
||||
return _fixedStepInterpolation;
|
||||
}
|
||||
|
||||
// TODO: VR Frame Time Override - used to sync physics with VR headset refresh rate
|
||||
#if lnx_vr
|
||||
public static var vrFrameTime: Float = -1.0; // VR frame time in seconds (-1 = not in VR)
|
||||
static var lastVRFrameTime: Float = 0.0;
|
||||
static var vrFrameCount: Int = 0;
|
||||
static var normalModeLogged: Bool = false;
|
||||
#end
|
||||
|
||||
static var lastTime = 0.0;
|
||||
static var _delta = 0.0;
|
||||
public static var delta(get, never): Float;
|
||||
static function get_delta(): Float {
|
||||
return _delta;
|
||||
}
|
||||
|
||||
|
||||
static var lastRenderTime = 0.0;
|
||||
static var _renderDelta = 0.0;
|
||||
public static var renderDelta(get, never): Float;
|
||||
static function get_renderDelta(): Float {
|
||||
return _renderDelta;
|
||||
}
|
||||
|
||||
|
||||
public static inline function time(): Float {
|
||||
return kha.Scheduler.time() * scale;
|
||||
return kha.Scheduler.time();
|
||||
}
|
||||
|
||||
|
||||
public static inline function realTime(): Float {
|
||||
return kha.Scheduler.realTime() * scale;
|
||||
return kha.Scheduler.realTime();
|
||||
}
|
||||
|
||||
public static function update() {
|
||||
#if lnx_vr
|
||||
// TODO: use VR frame time when in VR present mode to sync physics with headset refresh
|
||||
// TODO: use VR frame time when in VR present mode to sync physics with VR headset refresh
|
||||
if (vrFrameTime >= 0.0) {
|
||||
if (lastVRFrameTime > 0.0) {
|
||||
_delta = vrFrameTime - lastVRFrameTime;
|
||||
|
||||
Reference in New Issue
Block a user