pub struct FixedTimestep3DSession { /* private fields */ }Expand description
Decoupled 3D fixed-timestep simulation loop maintaining invariant physics step counts across 60/120/144/240Hz presentation cadences.
Implementations§
Source§impl FixedTimestep3DSession
Decoupled fixed-timestep simulation stepping and render interpolation helpers for FixedTimestep3DSession.
impl FixedTimestep3DSession
Decoupled fixed-timestep simulation stepping and render interpolation helpers for FixedTimestep3DSession.
Sourcepub fn new(sim_hz: u32, max_substeps: u32, present_hz: f32) -> Self
pub fn new(sim_hz: u32, max_substeps: u32, present_hz: f32) -> Self
Constructs a FixedTimestep3DSession with explicit fixed simulation frequency, substep cap, and presentation cadence.
§Arguments
u32- Fixed simulation frequency in Hertz (1..=1000).u32- Maximum fixed substeps allowed per presentation frame to prevent spiral-of-death stalls.f32- Display presentation cadence in Hertz (e.g.60.0,120.0,144.0,240.0).
§Returns
Self- Configured decoupled 3D simulation session.
Sourcepub fn set_present_cadence_hz(&mut self, present_hz: f32)
pub fn set_present_cadence_hz(&mut self, present_hz: f32)
Updates the display presentation cadence in Hertz without altering the fixed simulation timestep or accumulator.
§Arguments
&Self- Mutable simulation session.f32- New presentation cadence in Hertz (1.0..=1000.0).
Sourcepub fn advance_present_ns<F>(
&mut self,
present_dt_ns: u64,
step_sim: F,
) -> SimPresentFrame
pub fn advance_present_ns<F>( &mut self, present_dt_ns: u64, step_sim: F, ) -> SimPresentFrame
Advances the decoupled loop by present_dt_ns nanoseconds, executing only the required fixed simulation steps and returning render interpolation alpha.
§Arguments
&Self- Mutable simulation session.u64- Elapsed presentation interval in integer nanoseconds.F- Fixed-timestep simulation callback invoked once per fixed substep withfixed_dt_secs.
§Returns
SimPresentFrame- Per-present step count, interpolation alpha, and clamp flags.
Sourcepub fn advance_present<F>(
&mut self,
present_dt_secs: f32,
step_sim: F,
) -> SimPresentFrame
pub fn advance_present<F>( &mut self, present_dt_secs: f32, step_sim: F, ) -> SimPresentFrame
Advances the decoupled loop by present_dt_secs seconds (converted to integer nanoseconds) and returns render interpolation metadata.
§Arguments
&Self- Mutable simulation session.f32- Elapsed presentation interval in seconds.F- Fixed-timestep simulation callback invoked once per fixed substep withfixed_dt_secs.
§Returns
SimPresentFrame- Per-present step count, interpolation alpha, and clamp flags.
Sourcepub fn interpolate_scalar(prev: f32, next: f32, alpha: f32) -> f32
pub fn interpolate_scalar(prev: f32, next: f32, alpha: f32) -> f32
Linearly interpolates between prev and next simulation scalar values using alpha clamped to [0.0, 1.0].
§Arguments
f32- Previous fixed simulation scalar value.f32- Latest fixed simulation scalar value.f32- Render interpolation factor in[0.0, 1.0].
§Returns
f32- Smoothly interpolated render scalar value.
Source§impl FixedTimestep3DSession
impl FixedTimestep3DSession
pub fn get_clock(&self) -> FrameClock
pub fn get_mut_clock(&mut self) -> &mut FrameClock
pub fn set_clock(&mut self, val: FrameClock) -> &mut Self
pub fn get_present_hz(&self) -> f32
pub fn get_mut_present_hz(&mut self) -> &mut f32
pub fn set_present_hz(&mut self, val: f32) -> &mut Self
pub fn get_sim_steps_total(&self) -> u64
pub fn get_mut_sim_steps_total(&mut self) -> &mut u64
pub fn set_sim_steps_total(&mut self, val: u64) -> &mut Self
pub fn get_present_frames_total(&self) -> u64
pub fn get_mut_present_frames_total(&mut self) -> &mut u64
pub fn set_present_frames_total(&mut self, val: u64) -> &mut Self
pub fn get_interpolated_only_frames(&self) -> u64
pub fn get_mut_interpolated_only_frames(&mut self) -> &mut u64
pub fn set_interpolated_only_frames(&mut self, val: u64) -> &mut Self
pub fn get_clamped_stall_frames(&self) -> u64
pub fn get_mut_clamped_stall_frames(&mut self) -> &mut u64
pub fn set_clamped_stall_frames(&mut self, val: u64) -> &mut Self
pub fn get_last_alpha(&self) -> f32
pub fn get_mut_last_alpha(&mut self) -> &mut f32
pub fn set_last_alpha(&mut self, val: f32) -> &mut Self
pub fn get_last_steps(&self) -> u32
pub fn get_mut_last_steps(&mut self) -> &mut u32
pub fn set_last_steps(&mut self, val: u32) -> &mut Self
Trait Implementations§
Source§impl Clone for FixedTimestep3DSession
impl Clone for FixedTimestep3DSession
impl Copy for FixedTimestep3DSession
Source§impl Debug for FixedTimestep3DSession
impl Debug for FixedTimestep3DSession
Source§impl Default for FixedTimestep3DSession
Default 60Hz fixed simulation / 60Hz presentation FixedTimestep3DSession.
impl Default for FixedTimestep3DSession
Default 60Hz fixed simulation / 60Hz presentation FixedTimestep3DSession.