diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index fa86e82b9e..e437769d41 100755 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -1005,7 +1005,7 @@ pub fn advance_animations( animation_graphs: Res>, mut players: Query<(&mut AnimationPlayer, &AnimationGraphHandle)>, ) { - let delta_seconds = time.delta_seconds(); + let delta_seconds = time.delta_secs(); players .par_iter_mut() .for_each(|(mut player, graph_handle)| { diff --git a/crates/bevy_animation/src/transition.rs b/crates/bevy_animation/src/transition.rs index 3b9eaa2805..679c63bec3 100644 --- a/crates/bevy_animation/src/transition.rs +++ b/crates/bevy_animation/src/transition.rs @@ -122,7 +122,7 @@ pub fn advance_transitions( for transition in &mut animation_transitions.transitions.iter_mut().rev() { // Decrease weight. transition.current_weight = (transition.current_weight - - transition.weight_decline_per_sec * time.delta_seconds()) + - transition.weight_decline_per_sec * time.delta_secs()) .max(0.0); // Update weight. diff --git a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs index 99a7270617..040a05773c 100644 --- a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs @@ -33,7 +33,7 @@ impl FrameTimeDiagnosticsPlugin { ) { diagnostics.add_measurement(&Self::FRAME_COUNT, || frame_count.0 as f64); - let delta_seconds = time.delta_seconds_f64(); + let delta_seconds = time.delta_secs_f64(); if delta_seconds == 0.0 { return; } diff --git a/crates/bevy_render/src/globals.rs b/crates/bevy_render/src/globals.rs index e89648fb56..eabaaad05e 100644 --- a/crates/bevy_render/src/globals.rs +++ b/crates/bevy_render/src/globals.rs @@ -74,8 +74,8 @@ fn prepare_globals_buffer( frame_count: Res, ) { let buffer = globals_buffer.buffer.get_mut(); - buffer.time = time.elapsed_seconds_wrapped(); - buffer.delta_time = time.delta_seconds(); + buffer.time = time.elapsed_secs_wrapped(); + buffer.delta_time = time.delta_secs(); buffer.frame_count = frame_count.0; globals_buffer diff --git a/crates/bevy_time/src/stopwatch.rs b/crates/bevy_time/src/stopwatch.rs index 352749848d..b604a8890b 100644 --- a/crates/bevy_time/src/stopwatch.rs +++ b/crates/bevy_time/src/stopwatch.rs @@ -21,7 +21,7 @@ use bevy_utils::Duration; /// assert_eq!(stopwatch.elapsed_secs(), 1.0); /// /// stopwatch.reset(); // reset the stopwatch -/// assert!(stopwatch.paused()); +/// assert!(stopwatch.is_paused()); /// assert_eq!(stopwatch.elapsed_secs(), 0.0); /// ``` #[derive(Clone, Debug, Default, PartialEq, Eq)] @@ -29,7 +29,7 @@ use bevy_utils::Duration; #[cfg_attr(feature = "bevy_reflect", derive(Reflect), reflect(Default))] pub struct Stopwatch { elapsed: Duration, - paused: bool, + is_paused: bool, } impl Stopwatch { @@ -40,7 +40,7 @@ impl Stopwatch { /// # use bevy_time::*; /// let stopwatch = Stopwatch::new(); /// assert_eq!(stopwatch.elapsed_secs(), 0.0); - /// assert_eq!(stopwatch.paused(), false); + /// assert_eq!(stopwatch.is_paused(), false); /// ``` pub fn new() -> Self { Default::default() @@ -128,7 +128,7 @@ impl Stopwatch { /// assert_eq!(stopwatch.elapsed_secs(), 1.5); /// ``` pub fn tick(&mut self, delta: Duration) -> &Self { - if !self.paused() { + if !self.is_paused() { self.elapsed = self.elapsed.saturating_add(delta); } self @@ -144,12 +144,12 @@ impl Stopwatch { /// let mut stopwatch = Stopwatch::new(); /// stopwatch.pause(); /// stopwatch.tick(Duration::from_secs_f32(1.5)); - /// assert!(stopwatch.paused()); + /// assert!(stopwatch.is_paused()); /// assert_eq!(stopwatch.elapsed_secs(), 0.0); /// ``` #[inline] pub fn pause(&mut self) { - self.paused = true; + self.is_paused = true; } /// Unpauses the stopwatch. Resume the effect of ticking on elapsed time. @@ -163,12 +163,12 @@ impl Stopwatch { /// stopwatch.tick(Duration::from_secs_f32(1.0)); /// stopwatch.unpause(); /// stopwatch.tick(Duration::from_secs_f32(1.0)); - /// assert!(!stopwatch.paused()); + /// assert!(!stopwatch.is_paused()); /// assert_eq!(stopwatch.elapsed_secs(), 1.0); /// ``` #[inline] pub fn unpause(&mut self) { - self.paused = false; + self.is_paused = false; } /// Returns `true` if the stopwatch is paused. @@ -177,15 +177,15 @@ impl Stopwatch { /// ``` /// # use bevy_time::*; /// let mut stopwatch = Stopwatch::new(); - /// assert!(!stopwatch.paused()); + /// assert!(!stopwatch.is_paused()); /// stopwatch.pause(); - /// assert!(stopwatch.paused()); + /// assert!(stopwatch.is_paused()); /// stopwatch.unpause(); - /// assert!(!stopwatch.paused()); + /// assert!(!stopwatch.is_paused()); /// ``` #[inline] - pub fn paused(&self) -> bool { - self.paused + pub fn is_paused(&self) -> bool { + self.is_paused } /// Resets the stopwatch. The reset doesn't affect the paused state of the stopwatch. diff --git a/crates/bevy_time/src/time.rs b/crates/bevy_time/src/time.rs index 739f7f6742..3db9bef56d 100644 --- a/crates/bevy_time/src/time.rs +++ b/crates/bevy_time/src/time.rs @@ -30,15 +30,15 @@ use { /// which will set [`delta()`](Time::delta) to zero. /// /// These values are also available in seconds as `f32` via -/// [`delta_seconds()`](Time::delta_seconds) and -/// [`elapsed_seconds()`](Time::elapsed_seconds), and also in seconds as `f64` -/// via [`delta_seconds_f64()`](Time::delta_seconds_f64) and -/// [`elapsed_seconds_f64()`](Time::elapsed_seconds_f64). +/// [`delta_secs()`](Time::delta_secs) and +/// [`elapsed_secs()`](Time::elapsed_secs), and also in seconds as `f64` +/// via [`delta_secs_f64()`](Time::delta_secs_f64) and +/// [`elapsed_secs_f64()`](Time::elapsed_secs_f64). /// -/// Since [`elapsed_seconds()`](Time::elapsed_seconds) will grow constantly and +/// Since [`elapsed_secs()`](Time::elapsed_secs) will grow constantly and /// is `f32`, it will exhibit gradual precision loss. For applications that /// require an `f32` value but suffer from gradual precision loss there is -/// [`elapsed_seconds_wrapped()`](Time::elapsed_seconds_wrapped) available. The +/// [`elapsed_secs_wrapped()`](Time::elapsed_secs_wrapped) available. The /// same wrapped value is also available as [`Duration`] and `f64` for /// consistency. The wrap period is by default 1 hour, and can be set by /// [`set_wrap_period()`](Time::set_wrap_period). @@ -193,14 +193,14 @@ pub struct Time { context: T, wrap_period: Duration, delta: Duration, - delta_seconds: f32, - delta_seconds_f64: f64, + delta_secs: f32, + delta_secs_f64: f64, elapsed: Duration, - elapsed_seconds: f32, - elapsed_seconds_f64: f64, + elapsed_secs: f32, + elapsed_secs_f64: f64, elapsed_wrapped: Duration, - elapsed_seconds_wrapped: f32, - elapsed_seconds_wrapped_f64: f64, + elapsed_secs_wrapped: f32, + elapsed_secs_wrapped_f64: f64, } impl Time { @@ -222,14 +222,14 @@ impl Time { /// [`Duration::ZERO`] is allowed and will set [`Self::delta`] to zero. pub fn advance_by(&mut self, delta: Duration) { self.delta = delta; - self.delta_seconds = self.delta.as_secs_f32(); - self.delta_seconds_f64 = self.delta.as_secs_f64(); + self.delta_secs = self.delta.as_secs_f32(); + self.delta_secs_f64 = self.delta.as_secs_f64(); self.elapsed += delta; - self.elapsed_seconds = self.elapsed.as_secs_f32(); - self.elapsed_seconds_f64 = self.elapsed.as_secs_f64(); + self.elapsed_secs = self.elapsed.as_secs_f32(); + self.elapsed_secs_f64 = self.elapsed.as_secs_f64(); self.elapsed_wrapped = duration_rem(self.elapsed, self.wrap_period); - self.elapsed_seconds_wrapped = self.elapsed_wrapped.as_secs_f32(); - self.elapsed_seconds_wrapped_f64 = self.elapsed_wrapped.as_secs_f64(); + self.elapsed_secs_wrapped = self.elapsed_wrapped.as_secs_f32(); + self.elapsed_secs_wrapped_f64 = self.elapsed_wrapped.as_secs_f64(); } /// Advance this clock to a specific `elapsed` time. @@ -280,15 +280,15 @@ impl Time { /// Returns how much time has advanced since the last [`update`](#method.update), as [`f32`] /// seconds. #[inline] - pub fn delta_seconds(&self) -> f32 { - self.delta_seconds + pub fn delta_secs(&self) -> f32 { + self.delta_secs } /// Returns how much time has advanced since the last [`update`](#method.update), as [`f64`] /// seconds. #[inline] - pub fn delta_seconds_f64(&self) -> f64 { - self.delta_seconds_f64 + pub fn delta_secs_f64(&self) -> f64 { + self.delta_secs_f64 } /// Returns how much time has advanced since [`startup`](#method.startup), as [`Duration`]. @@ -301,16 +301,16 @@ impl Time { /// /// **Note:** This is a monotonically increasing value. Its precision will degrade over time. /// If you need an `f32` but that precision loss is unacceptable, - /// use [`elapsed_seconds_wrapped`](#method.elapsed_seconds_wrapped). + /// use [`elapsed_secs_wrapped`](#method.elapsed_secs_wrapped). #[inline] - pub fn elapsed_seconds(&self) -> f32 { - self.elapsed_seconds + pub fn elapsed_secs(&self) -> f32 { + self.elapsed_secs } /// Returns how much time has advanced since [`startup`](#method.startup), as [`f64`] seconds. #[inline] - pub fn elapsed_seconds_f64(&self) -> f64 { - self.elapsed_seconds_f64 + pub fn elapsed_secs_f64(&self) -> f64 { + self.elapsed_secs_f64 } /// Returns how much time has advanced since [`startup`](#method.startup) modulo @@ -324,17 +324,17 @@ impl Time { /// the [`wrap_period`](#method.wrap_period), as [`f32`] seconds. /// /// This method is intended for applications (e.g. shaders) that require an [`f32`] value but - /// suffer from the gradual precision loss of [`elapsed_seconds`](#method.elapsed_seconds). + /// suffer from the gradual precision loss of [`elapsed_secs`](#method.elapsed_secs). #[inline] - pub fn elapsed_seconds_wrapped(&self) -> f32 { - self.elapsed_seconds_wrapped + pub fn elapsed_secs_wrapped(&self) -> f32 { + self.elapsed_secs_wrapped } /// Returns how much time has advanced since [`startup`](#method.startup) modulo /// the [`wrap_period`](#method.wrap_period), as [`f64`] seconds. #[inline] - pub fn elapsed_seconds_wrapped_f64(&self) -> f64 { - self.elapsed_seconds_wrapped_f64 + pub fn elapsed_secs_wrapped_f64(&self) -> f64 { + self.elapsed_secs_wrapped_f64 } /// Returns a reference to the context of this specific clock. @@ -356,14 +356,14 @@ impl Time { context: (), wrap_period: self.wrap_period, delta: self.delta, - delta_seconds: self.delta_seconds, - delta_seconds_f64: self.delta_seconds_f64, + delta_secs: self.delta_secs, + delta_secs_f64: self.delta_secs_f64, elapsed: self.elapsed, - elapsed_seconds: self.elapsed_seconds, - elapsed_seconds_f64: self.elapsed_seconds_f64, + elapsed_secs: self.elapsed_secs, + elapsed_secs_f64: self.elapsed_secs_f64, elapsed_wrapped: self.elapsed_wrapped, - elapsed_seconds_wrapped: self.elapsed_seconds_wrapped, - elapsed_seconds_wrapped_f64: self.elapsed_seconds_wrapped_f64, + elapsed_secs_wrapped: self.elapsed_secs_wrapped, + elapsed_secs_wrapped_f64: self.elapsed_secs_wrapped_f64, } } } @@ -374,14 +374,14 @@ impl Default for Time { context: Default::default(), wrap_period: Self::DEFAULT_WRAP_PERIOD, delta: Duration::ZERO, - delta_seconds: 0.0, - delta_seconds_f64: 0.0, + delta_secs: 0.0, + delta_secs_f64: 0.0, elapsed: Duration::ZERO, - elapsed_seconds: 0.0, - elapsed_seconds_f64: 0.0, + elapsed_secs: 0.0, + elapsed_secs_f64: 0.0, elapsed_wrapped: Duration::ZERO, - elapsed_seconds_wrapped: 0.0, - elapsed_seconds_wrapped_f64: 0.0, + elapsed_secs_wrapped: 0.0, + elapsed_secs_wrapped_f64: 0.0, } } } @@ -402,14 +402,14 @@ mod test { assert_eq!(time.wrap_period(), Time::<()>::DEFAULT_WRAP_PERIOD); assert_eq!(time.delta(), Duration::ZERO); - assert_eq!(time.delta_seconds(), 0.0); - assert_eq!(time.delta_seconds_f64(), 0.0); + assert_eq!(time.delta_secs(), 0.0); + assert_eq!(time.delta_secs_f64(), 0.0); assert_eq!(time.elapsed(), Duration::ZERO); - assert_eq!(time.elapsed_seconds(), 0.0); - assert_eq!(time.elapsed_seconds_f64(), 0.0); + assert_eq!(time.elapsed_secs(), 0.0); + assert_eq!(time.elapsed_secs_f64(), 0.0); assert_eq!(time.elapsed_wrapped(), Duration::ZERO); - assert_eq!(time.elapsed_seconds_wrapped(), 0.0); - assert_eq!(time.elapsed_seconds_wrapped_f64(), 0.0); + assert_eq!(time.elapsed_secs_wrapped(), 0.0); + assert_eq!(time.elapsed_secs_wrapped_f64(), 0.0); } #[test] @@ -419,29 +419,29 @@ mod test { time.advance_by(Duration::from_millis(250)); assert_eq!(time.delta(), Duration::from_millis(250)); - assert_eq!(time.delta_seconds(), 0.25); - assert_eq!(time.delta_seconds_f64(), 0.25); + assert_eq!(time.delta_secs(), 0.25); + assert_eq!(time.delta_secs_f64(), 0.25); assert_eq!(time.elapsed(), Duration::from_millis(250)); - assert_eq!(time.elapsed_seconds(), 0.25); - assert_eq!(time.elapsed_seconds_f64(), 0.25); + assert_eq!(time.elapsed_secs(), 0.25); + assert_eq!(time.elapsed_secs_f64(), 0.25); time.advance_by(Duration::from_millis(500)); assert_eq!(time.delta(), Duration::from_millis(500)); - assert_eq!(time.delta_seconds(), 0.5); - assert_eq!(time.delta_seconds_f64(), 0.5); + assert_eq!(time.delta_secs(), 0.5); + assert_eq!(time.delta_secs_f64(), 0.5); assert_eq!(time.elapsed(), Duration::from_millis(750)); - assert_eq!(time.elapsed_seconds(), 0.75); - assert_eq!(time.elapsed_seconds_f64(), 0.75); + assert_eq!(time.elapsed_secs(), 0.75); + assert_eq!(time.elapsed_secs_f64(), 0.75); time.advance_by(Duration::ZERO); assert_eq!(time.delta(), Duration::ZERO); - assert_eq!(time.delta_seconds(), 0.0); - assert_eq!(time.delta_seconds_f64(), 0.0); + assert_eq!(time.delta_secs(), 0.0); + assert_eq!(time.delta_secs_f64(), 0.0); assert_eq!(time.elapsed(), Duration::from_millis(750)); - assert_eq!(time.elapsed_seconds(), 0.75); - assert_eq!(time.elapsed_seconds_f64(), 0.75); + assert_eq!(time.elapsed_secs(), 0.75); + assert_eq!(time.elapsed_secs_f64(), 0.75); } #[test] @@ -451,29 +451,29 @@ mod test { time.advance_to(Duration::from_millis(250)); assert_eq!(time.delta(), Duration::from_millis(250)); - assert_eq!(time.delta_seconds(), 0.25); - assert_eq!(time.delta_seconds_f64(), 0.25); + assert_eq!(time.delta_secs(), 0.25); + assert_eq!(time.delta_secs_f64(), 0.25); assert_eq!(time.elapsed(), Duration::from_millis(250)); - assert_eq!(time.elapsed_seconds(), 0.25); - assert_eq!(time.elapsed_seconds_f64(), 0.25); + assert_eq!(time.elapsed_secs(), 0.25); + assert_eq!(time.elapsed_secs_f64(), 0.25); time.advance_to(Duration::from_millis(750)); assert_eq!(time.delta(), Duration::from_millis(500)); - assert_eq!(time.delta_seconds(), 0.5); - assert_eq!(time.delta_seconds_f64(), 0.5); + assert_eq!(time.delta_secs(), 0.5); + assert_eq!(time.delta_secs_f64(), 0.5); assert_eq!(time.elapsed(), Duration::from_millis(750)); - assert_eq!(time.elapsed_seconds(), 0.75); - assert_eq!(time.elapsed_seconds_f64(), 0.75); + assert_eq!(time.elapsed_secs(), 0.75); + assert_eq!(time.elapsed_secs_f64(), 0.75); time.advance_to(Duration::from_millis(750)); assert_eq!(time.delta(), Duration::ZERO); - assert_eq!(time.delta_seconds(), 0.0); - assert_eq!(time.delta_seconds_f64(), 0.0); + assert_eq!(time.delta_secs(), 0.0); + assert_eq!(time.delta_secs_f64(), 0.0); assert_eq!(time.elapsed(), Duration::from_millis(750)); - assert_eq!(time.elapsed_seconds(), 0.75); - assert_eq!(time.elapsed_seconds_f64(), 0.75); + assert_eq!(time.elapsed_secs(), 0.75); + assert_eq!(time.elapsed_secs_f64(), 0.75); } #[test] @@ -494,26 +494,26 @@ mod test { time.advance_by(Duration::from_secs(2)); assert_eq!(time.elapsed_wrapped(), Duration::from_secs(2)); - assert_eq!(time.elapsed_seconds_wrapped(), 2.0); - assert_eq!(time.elapsed_seconds_wrapped_f64(), 2.0); + assert_eq!(time.elapsed_secs_wrapped(), 2.0); + assert_eq!(time.elapsed_secs_wrapped_f64(), 2.0); time.advance_by(Duration::from_secs(2)); assert_eq!(time.elapsed_wrapped(), Duration::from_secs(1)); - assert_eq!(time.elapsed_seconds_wrapped(), 1.0); - assert_eq!(time.elapsed_seconds_wrapped_f64(), 1.0); + assert_eq!(time.elapsed_secs_wrapped(), 1.0); + assert_eq!(time.elapsed_secs_wrapped_f64(), 1.0); time.advance_by(Duration::from_secs(2)); assert_eq!(time.elapsed_wrapped(), Duration::ZERO); - assert_eq!(time.elapsed_seconds_wrapped(), 0.0); - assert_eq!(time.elapsed_seconds_wrapped_f64(), 0.0); + assert_eq!(time.elapsed_secs_wrapped(), 0.0); + assert_eq!(time.elapsed_secs_wrapped_f64(), 0.0); time.advance_by(Duration::new(3, 250_000_000)); assert_eq!(time.elapsed_wrapped(), Duration::from_millis(250)); - assert_eq!(time.elapsed_seconds_wrapped(), 0.25); - assert_eq!(time.elapsed_seconds_wrapped_f64(), 0.25); + assert_eq!(time.elapsed_secs_wrapped(), 0.25); + assert_eq!(time.elapsed_secs_wrapped_f64(), 0.25); } #[test] @@ -524,14 +524,14 @@ mod test { time.advance_by(Duration::from_secs(8)); assert_eq!(time.elapsed_wrapped(), Duration::from_secs(3)); - assert_eq!(time.elapsed_seconds_wrapped(), 3.0); - assert_eq!(time.elapsed_seconds_wrapped_f64(), 3.0); + assert_eq!(time.elapsed_secs_wrapped(), 3.0); + assert_eq!(time.elapsed_secs_wrapped_f64(), 3.0); time.set_wrap_period(Duration::from_secs(2)); assert_eq!(time.elapsed_wrapped(), Duration::from_secs(3)); - assert_eq!(time.elapsed_seconds_wrapped(), 3.0); - assert_eq!(time.elapsed_seconds_wrapped_f64(), 3.0); + assert_eq!(time.elapsed_secs_wrapped(), 3.0); + assert_eq!(time.elapsed_secs_wrapped_f64(), 3.0); time.advance_by(Duration::ZERO); @@ -539,7 +539,7 @@ mod test { // is left in `elapsed_wrapped()`. This test of values is here to ensure // that we notice if we change that behaviour. assert_eq!(time.elapsed_wrapped(), Duration::from_secs(0)); - assert_eq!(time.elapsed_seconds_wrapped(), 0.0); - assert_eq!(time.elapsed_seconds_wrapped_f64(), 0.0); + assert_eq!(time.elapsed_secs_wrapped(), 0.0); + assert_eq!(time.elapsed_secs_wrapped_f64(), 0.0); } } diff --git a/crates/bevy_time/src/timer.rs b/crates/bevy_time/src/timer.rs index c594a73140..8e88f8c2dd 100644 --- a/crates/bevy_time/src/timer.rs +++ b/crates/bevy_time/src/timer.rs @@ -120,6 +120,13 @@ impl Timer { self.stopwatch.elapsed_secs() } + /// Returns the time elapsed on the timer as an `f64`. + /// See also [`Timer::elapsed`](Timer::elapsed). + #[inline] + pub fn elapsed_secs_f64(&self) -> f64 { + self.stopwatch.elapsed_secs_f64() + } + /// Sets the elapsed time of the timer without any other considerations. /// /// See also [`Stopwatch::set`](Stopwatch::set). @@ -299,7 +306,7 @@ impl Timer { /// Returns `true` if the timer is paused. /// - /// See also [`Stopwatch::paused`](Stopwatch::paused). + /// See also [`Stopwatch::is_paused`](Stopwatch::is_paused). /// /// # Examples /// ``` @@ -313,7 +320,7 @@ impl Timer { /// ``` #[inline] pub fn paused(&self) -> bool { - self.stopwatch.paused() + self.stopwatch.is_paused() } /// Resets the timer. The reset doesn't affect the `paused` state of the timer. @@ -450,6 +457,7 @@ mod tests { // Tick once, check all attributes t.tick(Duration::from_secs_f32(0.25)); assert_eq!(t.elapsed_secs(), 0.25); + assert_eq!(t.elapsed_secs_f64(), 0.25); assert_eq!(t.duration(), Duration::from_secs_f32(10.0)); assert!(!t.finished()); assert!(!t.just_finished()); @@ -472,6 +480,7 @@ mod tests { t.unpause(); t.tick(Duration::from_secs_f32(500.0)); assert_eq!(t.elapsed_secs(), 10.0); + assert_eq!(t.elapsed_secs_f64(), 10.0); assert!(t.finished()); assert!(t.just_finished()); assert_eq!(t.times_finished_this_tick(), 1); @@ -480,6 +489,7 @@ mod tests { // Continuing to tick when finished should only change just_finished t.tick(Duration::from_secs_f32(1.0)); assert_eq!(t.elapsed_secs(), 10.0); + assert_eq!(t.elapsed_secs_f64(), 10.0); assert!(t.finished()); assert!(!t.just_finished()); assert_eq!(t.times_finished_this_tick(), 0); @@ -493,6 +503,7 @@ mod tests { // Tick once, check all attributes t.tick(Duration::from_secs_f32(0.75)); assert_eq!(t.elapsed_secs(), 0.75); + assert_eq!(t.elapsed_secs_f64(), 0.75); assert_eq!(t.duration(), Duration::from_secs_f32(2.0)); assert!(!t.finished()); assert!(!t.just_finished()); @@ -503,6 +514,7 @@ mod tests { // Tick past the end and make sure elapsed wraps t.tick(Duration::from_secs_f32(1.5)); assert_eq!(t.elapsed_secs(), 0.25); + assert_eq!(t.elapsed_secs_f64(), 0.25); assert!(t.finished()); assert!(t.just_finished()); assert_eq!(t.times_finished_this_tick(), 1); @@ -511,6 +523,7 @@ mod tests { // Continuing to tick should turn off both finished & just_finished for repeating timers t.tick(Duration::from_secs_f32(1.0)); assert_eq!(t.elapsed_secs(), 1.25); + assert_eq!(t.elapsed_secs_f64(), 1.25); assert!(!t.finished()); assert!(!t.just_finished()); assert_eq!(t.times_finished_this_tick(), 0); @@ -525,6 +538,7 @@ mod tests { t.tick(Duration::from_secs_f32(3.5)); assert_eq!(t.times_finished_this_tick(), 3); assert_eq!(t.elapsed_secs(), 0.5); + assert_eq!(t.elapsed_secs_f64(), 0.5); assert!(t.finished()); assert!(t.just_finished()); t.tick(Duration::from_secs_f32(0.2)); diff --git a/examples/2d/bloom_2d.rs b/examples/2d/bloom_2d.rs index 3ffe6e1181..7613728baa 100644 --- a/examples/2d/bloom_2d.rs +++ b/examples/2d/bloom_2d.rs @@ -112,7 +112,7 @@ fn update_bloom_settings( commands.entity(entity).remove::(); } - let dt = time.delta_seconds(); + let dt = time.delta_secs(); if keycode.pressed(KeyCode::KeyA) { bloom.intensity -= dt / 10.0; diff --git a/examples/2d/bounding_2d.rs b/examples/2d/bounding_2d.rs index b5e9445be0..ff4d371d93 100644 --- a/examples/2d/bounding_2d.rs +++ b/examples/2d/bounding_2d.rs @@ -38,7 +38,7 @@ struct Spin; fn spin(time: Res