FTime
The process-wide frame clock: one real time that never stretches, one game time that does, and the frame number everything else keys off.
- Module
- Core
- Header
#include "Core/FTime.h"- Namespace
Mowo
Every accessor is out-of-line and the state lives in exactly one translation unit inside Core.dll. Nothing here may become an inline member reading a header-declared static — that shape gives each consuming DLL its own copy of the clock, and two modules then disagree about what frame it is without anything failing loudly.
Properties
| Type | Name | Description |
|---|---|---|
static constexpr int32_t | kMaxSmoothingFrames | Upper bound on the smoothing window, and the size of the ring the implementation keeps. Default 32. |
Public functions
| Returns | Name | Description |
|---|---|---|
void | BeginFrame | Advance one frame. |
void | BeginFrame | Same, measuring the delta off the platform clock. |
void | Reset | Frame 0, time 0, dilation 1, unpaused. |
double | GetRealTimeSeconds | Real time — never dilated, never paused. |
float | GetDeltaSeconds | |
float | GetUnclampedDeltaSeconds | |
uint64_t | GetFrameNumber | |
double | GetGameTimeSeconds | Game time — scaled by the dilation and frozen while paused. |
float | GetScaledDeltaSeconds | |
float | GetTimeDilation | |
void | SetTimeDilation | |
bool | IsPaused | |
void | SetPaused | |
float | GetEffectiveTimeDilation | The dilation actually in force: zero while paused. |
float | TimeSince | Game seconds elapsed since a game-time stamp. |
void | SetMaxDeltaSeconds | Delta clamp, 0.25 s by default. |
double | GetMaxDeltaSeconds | |
void | SetFixedDeltaSeconds | Fixed timestep. |
double | GetFixedDeltaSeconds | |
bool | IsUsingFixedTimestep | |
void | SetSmoothingFrames | Rolling mean across the last N clamped deltas. |
int32_t | GetSmoothingFrames | |
void | SetTargetFrameRate | Frame pacing. |
int32_t | GetTargetFrameRate | |
void | PaceFrame | |
double | SecondsUntilTarget | Seconds left before this frame's period at hz is up, or 0 when it is already over. |
void | InitFromCommandLine | Reads --fixed-dt=<seconds>, --fps=<hz> and --max-delta=<seconds>. |
double | GetPlatformSeconds | Monotonic platform seconds, independent of the frame loop. |
Function details
BeginFrame
static void BeginFrame(double rawDeltaSeconds)Advance one frame. Engine::Run is the single caller in a hosted process; headless drivers and tests call it themselves. rawDeltaSeconds is the measured wall time. The clamp, the smoothing window and the fixed-timestep override are applied in here so that no caller has to reproduce them.
BeginFrame
static void BeginFrame()Same, measuring the delta off the platform clock. The first call after Reset() reports a zero delta rather than the time since process start.
Reset
static void Reset()Frame 0, time 0, dilation 1, unpaused. Configuration (clamp, fixed step, smoothing window, frame cap) survives.
GetRealTimeSeconds
static double GetRealTimeSeconds()Real time — never dilated, never paused. Advances by the UNCLAMPED delta, so a hitch stays visible in the numbers a capture records.
GetDeltaSeconds
static float GetDeltaSeconds()GetUnclampedDeltaSeconds
static float GetUnclampedDeltaSeconds()GetFrameNumber
static uint64_t GetFrameNumber()GetGameTimeSeconds
static double GetGameTimeSeconds()Game time — scaled by the dilation and frozen while paused.
GetScaledDeltaSeconds
static float GetScaledDeltaSeconds()GetTimeDilation
static float GetTimeDilation()SetTimeDilation
static void SetTimeDilation(float dilation)IsPaused
static bool IsPaused()SetPaused
static void SetPaused(bool paused)GetEffectiveTimeDilation
static float GetEffectiveTimeDilation()The dilation actually in force: zero while paused. This is the factor a world applies to its tick delta.
TimeSince
static float TimeSince(double gameTimeSeconds)Game seconds elapsed since a game-time stamp. Constant across a pause, which is the reason gameplay stamps game time and not real time.
SetMaxDeltaSeconds
static void SetMaxDeltaSeconds(double seconds)Delta clamp, 0.25 s by default. A debugger break otherwise hands the physics step a delta it cannot integrate.
GetMaxDeltaSeconds
static double GetMaxDeltaSeconds()SetFixedDeltaSeconds
static void SetFixedDeltaSeconds(double seconds)Fixed timestep. Greater than zero makes every frame report exactly this delta whatever the wall clock did, which is what makes a capture replay to the same numbers. Set from --fixed-dt=<seconds> or --fps=<hz>.
GetFixedDeltaSeconds
static double GetFixedDeltaSeconds()IsUsingFixedTimestep
static bool IsUsingFixedTimestep()SetSmoothingFrames
static void SetSmoothingFrames(int32_t frames)Rolling mean across the last N clamped deltas. 0 or 1 = off (the default). Ignored under a fixed timestep.
GetSmoothingFrames
static int32_t GetSmoothingFrames()SetTargetFrameRate
static void SetTargetFrameRate(int32_t hz)Frame pacing. Sleeps the bulk of the remaining budget through the OS and spins only the last slice — a plain sleep overshoots by most of a scheduler tick, a plain spin burns a core for the whole frame. hz <= 0 returns immediately.
GetTargetFrameRate
static int32_t GetTargetFrameRate()PaceFrame
static void PaceFrame(int32_t hz, bool precise)SecondsUntilTarget
static double SecondsUntilTarget(int32_t hz)Seconds left before this frame's period at hz is up, or 0 when it is already over. For a caller that wants to wait that time on something other than a sleep — a throttled editor waits on the OS event queue so the first input after a pause is not stuck behind a 40 ms nap.
InitFromCommandLine
static void InitFromCommandLine()Reads --fixed-dt=<seconds>, --fps=<hz> and --max-delta=<seconds>. Idempotent; BeginFrame runs it once if nothing else did.
GetPlatformSeconds
static double GetPlatformSeconds()Monotonic platform seconds, independent of the frame loop. What PaceFrame measures against.