class SceneTime

Inherits: IScriptExportable

Manages simulation time for a particular scene.

This time runs only while scene is simulating.

Public

Constructors

SceneTime

SceneTime()

Methods

~SceneTime

~SceneTime() noexcept

GetTimeInSeconds

float GetTimeInSeconds() const

Gets the time since the simulation started playing, multiplied by the time scale factor.

In editor this will reset to zero every time you start playing in editor, and in a standalone application this will be similar to GetRealTimeInSeconds(), except simulation time can be sped up/down, or stopped entirely by setting the time scale.

Returns: Time since game start, affected by simulation time scale.

SetScale

void SetScale(float scale)

Allows you to speed time up or down, or completely pause it by providing zero.

Must be zero or larger.

GetScale

float GetScale() const

Returns the currently applied simulation time scale.

Reset

void Reset()

Resets the simulation time to zero.

Primarily used for editor purposes for resetting the time when ending play in editor.

SetPaused

void SetPaused(bool paused)

Pauses or unpauses the simulation time.

This is equivalent to setting the time scale to 0.

SetFixedDeltaTimeUs

void SetFixedDeltaTimeUs(u64 delta)

Sets a fixed delta time for deterministic simulation.

When enabled, the base frame delta uses this constant value before time scale is applied.

delta
Fixed time step in microseconds. 0 disables.

GetFixedFrameDelta

float GetFixedFrameDelta() const

Returns the step (in seconds) between fixed frame updates.

GetLastFixedUpdateTime

float GetLastFixedUpdateTime() const

Returns the time (in seconds) the latest fixed update has started.

Internal

Methods

Update

void Update()

Called every frame.

Should only be called by Application.

GetFixedUpdateStep

u32 GetFixedUpdateStep(u64 &outStep)

Calculates the number of fixed update iterations required and their step size.

Values depend on the current time and previous calls to AdvanceFixedUpdateInternal().;

outStep
Duration of the fixed step in microseconds. In most cases this is the same duration as the fixed time delta, but in the cases where frame is taking a very long time the step might be increased to avoid a large number of fixed updates per frame.

Returns: Returns the number of fixed frame updates to execute (each of duration). In most cases this will be either 1 or 0, or a larger amount of frames are taking a long time to execute (longer than a multiple of fixed frame step).

AdvanceFixedUpdate

void AdvanceFixedUpdate(u64 step)

Advances the fixed update timers by microseconds.

Should be called once for each iteration as returned by GetFixedUpdateStepInternal(), per frame.

Private

Fields

mFrameDelta

float mFrameDelta

Frame delta in seconds

mFirstFrame

bool mFirstFrame

mLastFrameTime

u64 mLastFrameTime

Time since last frame update call, In microseconds

mTimeInSeconds

float mTimeInSeconds

mTimeScale

float mTimeScale

mIsTimePaused

bool mIsTimePaused

mFixedStep

u64 mFixedStep

mLastFixedUpdateTime

u64 mLastFixedUpdateTime

mFirstFixedFrame

bool mFirstFixedFrame

mRemainingFixedUpdateCount

u32 mRemainingFixedUpdateCount

mFixedDeltaTimeMicrosec

u64 mFixedDeltaTimeMicrosec

Fixed delta time in microseconds (0 = disabled, use real-time)

mTimer

Timer * mTimer