Skip to main content

euv_core/game/clock/
struct.rs

1use super::*;
2
3/// Integer-nanosecond fixed-timestep accumulator with VSync-boundary hysteresis and dt-invariant FPS telemetry.
4#[derive(Clone, Copy, Data, Debug, PartialEq)]
5pub struct FrameClock {
6    /// Fixed simulation step duration in seconds (synchronized with `fixed_step_ns`).
7    #[get(type(copy))]
8    pub(crate) fixed_dt: f32,
9    /// Authoritative fixed simulation step duration in integer nanoseconds (`16_666_667` for 60Hz).
10    #[get(type(copy))]
11    pub(crate) fixed_step_ns: u64,
12    /// Upper cap on fixed substeps executed per rendered frame to prevent spiral-of-death stalls.
13    #[get(type(copy))]
14    pub(crate) max_substeps: u32,
15    /// Remaining accumulated simulation time in integer nanoseconds.
16    #[get(type(copy))]
17    pub(crate) accumulator_ns: u64,
18    /// Remaining accumulated simulation time in seconds (derived from `accumulator_ns`).
19    #[get(type(copy))]
20    pub(crate) accumulator: f32,
21    /// Clamped variable delta time of the most recent frame in integer nanoseconds.
22    #[get(type(copy))]
23    pub(crate) delta_ns: u64,
24    /// Clamped variable delta time of the most recent frame in seconds.
25    #[get(type(copy))]
26    pub(crate) delta_secs: f32,
27    /// Total elapsed wall/simulation time in integer nanoseconds.
28    #[get(type(copy))]
29    pub(crate) elapsed_ns: u64,
30    /// Total elapsed wall/simulation time in seconds.
31    #[get(type(copy))]
32    pub(crate) elapsed_secs: f64,
33    /// Interpolation alpha in `[0.0, 1.0]` between the previous and next fixed simulation states.
34    #[get(type(copy))]
35    pub(crate) alpha: f32,
36    /// Time-constant-invariant exponentially smoothed frames-per-second measurement.
37    #[get(type(copy))]
38    pub(crate) fps: f32,
39    /// Total rendered frames elapsed.
40    #[get(type(copy))]
41    pub(crate) frame_count: u64,
42    /// Total fixed simulation steps executed.
43    #[get(type(copy))]
44    pub(crate) fixed_step_count: u64,
45}