![]() |
vkmEngine 1.0.0
A C++ game engine · vkmengine.com
|
The engine's frame clock: real + simulation time and the fixed-step accumulator. More...
#include <clock.h>
Public Member Functions | |
| void | beginFrame () |
| Open a new frame: measure the real delta, derive the sim delta, fill the accumulator. | |
| bool | consumeFixedStep () |
| Take one fixed step if one is owed; the main-loop fixedUpdate condition. | |
| void | setTickRate (uint32_t ticksPerSecond) |
| Set the simulation cadence, in ticks per second. | |
| void | setPaused (bool paused) |
| Pause or resume simulation time. | |
| void | setTimeScale (float scale) |
| Set the slow-motion / fast-forward multiplier applied while running. | |
| void | setPacing (float scale) |
| Set how many fixed steps a second of wall time buys, as a multiple. | |
| void | requestStep (int steps=1) |
| Queue fixed-step advances, whatever the play state. | |
| float | getFixedAlpha () const |
| How far into the next fixed step this frame falls, 0..1. | |
| float | getFrameRate () const |
| Frames per second, smoothed over roughly the last half second. | |
| float | getFrameTime () const |
| The smoothed frame as a duration rather than a rate. | |
| bool | isSimulationStill () const |
| Whether the world stands still this frame. | |
| uint32_t | getTick () const |
| Which fixed step is running, counting from one. | |
The engine's frame clock: real + simulation time and the fixed-step accumulator.
Systems read getDeltaTime() for real-time work (input, camera, UI), getSimDelta() for simulation update() and getFixedStep() in fixedUpdate().
| void Vkm::Engine::Clock::beginFrame | ( | ) |
Open a new frame: measure the real delta, derive the sim delta, fill the accumulator.
The first call reports zero, so a slow startup gives no giant step. A frame longer than Config::MAX_FRAME_ACCUMULATOR is capped, so a hitch discards wall time.
| bool Vkm::Engine::Clock::consumeFixedStep | ( | ) |
Take one fixed step if one is owed; the main-loop fixedUpdate condition.
Requested steps are taken first, then measured time.
|
inline |
Set the simulation cadence, in ticks per second.
Set when a project is read, never per frame: fixedUpdate assumes a fixed step.
| ticksPerSecond | Clamped to [Config::MIN_TICK_RATE, Config::MAX_TICK_RATE]. |
|
inline |
Pause or resume simulation time.
Queued steps survive it.
| paused | True freezes simulation time (sim delta 0). |
|
inline |
Set the slow-motion / fast-forward multiplier applied while running.
In the editor a scale lasts one play session; see SceneIOController::endPlaySession.
| scale | Negative is clamped to 0. |
|
inline |
Set how many fixed steps a second of wall time buys, as a multiple.
A networked client runs slightly fast or slow so the server's command queue neither runs dry nor backs up (NetPacing); the step never changes. Multiplied with the time scale; Engine::run sets it each frame from NetSession::pacing().
| scale | Negative is clamped to 0. |
|
inline |
Queue fixed-step advances, whatever the play state.
A count, not seconds: a step is rarely a binary fraction, so n * step converted back would lose ticks.
| steps | Fixed steps to enqueue; non-positive is ignored. |
|
inline |
How far into the next fixed step this frame falls, 0..1.
The accumulator's leftover, as a fraction of a step past the last tick.
|
inline |
Frames per second, smoothed over roughly the last half second.
For this frame alone, use getDeltaTime().
|
inline |
The smoothed frame as a duration rather than a rate.
|
inline |
Whether the world stands still this frame.
True when no simulation time passes and no step is asked for, so no tick can follow; Engine::run drops input latched on such a frame.
|
inline |
Which fixed step is running, counting from one.
Advances only when consumeFixedStep() hands one out.