euv-core 0.48.3

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Integer-nanosecond fixed-timestep accumulator with VSync-boundary hysteresis and dt-invariant FPS telemetry.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct FrameClock {
    /// Fixed simulation step duration in seconds (synchronized with `fixed_step_ns`).
    #[get(type(copy))]
    pub(crate) fixed_dt: f32,
    /// Authoritative fixed simulation step duration in integer nanoseconds (`16_666_667` for 60Hz).
    #[get(type(copy))]
    pub(crate) fixed_step_ns: u64,
    /// Upper cap on fixed substeps executed per rendered frame to prevent spiral-of-death stalls.
    #[get(type(copy))]
    pub(crate) max_substeps: u32,
    /// Remaining accumulated simulation time in integer nanoseconds.
    #[get(type(copy))]
    pub(crate) accumulator_ns: u64,
    /// Remaining accumulated simulation time in seconds (derived from `accumulator_ns`).
    #[get(type(copy))]
    pub(crate) accumulator: f32,
    /// Clamped variable delta time of the most recent frame in integer nanoseconds.
    #[get(type(copy))]
    pub(crate) delta_ns: u64,
    /// Clamped variable delta time of the most recent frame in seconds.
    #[get(type(copy))]
    pub(crate) delta_secs: f32,
    /// Total elapsed wall/simulation time in integer nanoseconds.
    #[get(type(copy))]
    pub(crate) elapsed_ns: u64,
    /// Total elapsed wall/simulation time in seconds.
    #[get(type(copy))]
    pub(crate) elapsed_secs: f64,
    /// Interpolation alpha in `[0.0, 1.0]` between the previous and next fixed simulation states.
    #[get(type(copy))]
    pub(crate) alpha: f32,
    /// Time-constant-invariant exponentially smoothed frames-per-second measurement.
    #[get(type(copy))]
    pub(crate) fps: f32,
    /// Total rendered frames elapsed.
    #[get(type(copy))]
    pub(crate) frame_count: u64,
    /// Total fixed simulation steps executed.
    #[get(type(copy))]
    pub(crate) fixed_step_count: u64,
}

/// Per-present execution outcome emitted by `FixedTimestep3DSession` separating fixed simulation steps from presentation interpolation.
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct SimPresentFrame {
    /// Number of fixed-timestep simulation steps executed on this presentation tick (`0` on interpolated-only frames).
    #[get(type(copy))]
    pub(crate) fixed_steps_run: u32,
    /// Render interpolation factor in `[0.0, 1.0]` between the previous and latest fixed simulation snapshots.
    #[get(type(copy))]
    pub(crate) render_alpha: f32,
    /// Fixed simulation timestep duration in seconds.
    #[get(type(copy))]
    pub(crate) fixed_dt_secs: f32,
    /// Clamped presentation delta time in seconds for this frame.
    #[get(type(copy))]
    pub(crate) present_dt_secs: f32,
    /// True when this high-refresh presentation tick rendered an interpolated frame without re-running physics.
    #[get(type(copy))]
    pub(crate) interpolated_only: bool,
    /// True when `present_dt` hit the `max_substeps` spiral-of-death clamp.
    #[get(type(copy))]
    pub(crate) clamped_substeps: bool,
}

/// Decoupled 3D fixed-timestep simulation loop maintaining invariant physics step counts across 60/120/144/240Hz presentation cadences.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct FixedTimestep3DSession {
    /// Underlying integer-nanosecond fixed-timestep accumulator clock.
    #[get(type(copy))]
    pub(crate) clock: FrameClock,
    /// Active display presentation cadence in Hertz (e.g. `60.0`, `120.0`, `144.0`, `240.0`).
    #[get(type(copy))]
    pub(crate) present_hz: f32,
    /// Total fixed simulation steps executed across all presentation frames.
    #[get(type(copy))]
    pub(crate) sim_steps_total: u64,
    /// Total presentation frames rendered across all cadences.
    #[get(type(copy))]
    pub(crate) present_frames_total: u64,
    /// Count of presentation frames that rendered interpolated state without executing redundant physics steps.
    #[get(type(copy))]
    pub(crate) interpolated_only_frames: u64,
    /// Count of hitch frames clamped by `max_substeps` to prevent spiral-of-death stalls.
    #[get(type(copy))]
    pub(crate) clamped_stall_frames: u64,
    /// Most recent render interpolation alpha in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) last_alpha: f32,
    /// Most recent fixed step count executed on a single present frame.
    #[get(type(copy))]
    pub(crate) last_steps: u32,
}