#[derive(Debug, Clone, Copy, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[non_exhaustive]
pub struct FrameTime {
pub seconds: f64,
pub delta: f32,
pub frame_index: u64,
}
impl FrameTime {
pub fn new(seconds: f64, delta: f32, frame_index: u64) -> Self {
Self {
seconds,
delta,
frame_index,
}
}
pub fn fixed(seconds: f64) -> Self {
Self::new(seconds, 0.0, 0)
}
}
impl Default for FrameTime {
fn default() -> Self {
Self::fixed(0.0)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn fixed_has_zero_delta_and_index() {
let t = FrameTime::fixed(2.5);
assert_eq!(t, FrameTime::new(2.5, 0.0, 0));
assert_eq!(FrameTime::default(), FrameTime::fixed(0.0));
}
}