diff --git a/src/counters/timer.rs b/src/counters/timer.rs index 8b19055..88f7510 100644 --- a/src/counters/timer.rs +++ b/src/counters/timer.rs @@ -6,7 +6,7 @@ use web_time::Instant; pub struct Timer { enabled: bool, time: f64, - start: Option, + start: Option, } impl Timer { @@ -38,7 +38,7 @@ impl Timer { pub fn start(&mut self) { if self.enabled { self.time = 0.0; - self.start = Some(Instant::now().elapsed().as_secs_f64()); + self.start = Some(Instant::now()); } } @@ -46,7 +46,7 @@ impl Timer { pub fn pause(&mut self) { if self.enabled { if let Some(start) = self.start { - self.time += Instant::now().elapsed().as_secs_f64() - start; + self.time += start.elapsed().as_secs_f64(); } self.start = None; } @@ -55,7 +55,7 @@ impl Timer { /// Resume the timer. pub fn resume(&mut self) { if self.enabled { - self.start = Some(Instant::now().elapsed().as_secs_f64()); + self.start = Some(Instant::now()); } } diff --git a/src/integrations/rapier/harness_plugin.rs b/src/integrations/rapier/harness_plugin.rs index 981ecb9..136a4ba 100644 --- a/src/integrations/rapier/harness_plugin.rs +++ b/src/integrations/rapier/harness_plugin.rs @@ -58,7 +58,7 @@ impl HarnessPlugin for FluidsHarnessPlugin { } fn step(&mut self, physics: &mut PhysicsState, _run_state: &RunState) { - let step_time = Instant::now().elapsed().as_secs_f64(); + let step_time = Instant::now(); let dt = physics.integration_parameters.dt; self.fluids_pipeline.step( &physics.gravity, @@ -67,7 +67,7 @@ impl HarnessPlugin for FluidsHarnessPlugin { &mut physics.bodies, ); - self.step_time = Instant::now().elapsed().as_secs_f64() - step_time; + self.step_time = step_time.elapsed().as_secs_f64(); } fn profiling_string(&self) -> String { diff --git a/src/integrations/rapier/testbed_plugin.rs b/src/integrations/rapier/testbed_plugin.rs index f57b749..c3c0670 100644 --- a/src/integrations/rapier/testbed_plugin.rs +++ b/src/integrations/rapier/testbed_plugin.rs @@ -331,7 +331,7 @@ impl TestbedPlugin for FluidsTestbedPlugin { } fn step(&mut self, physics: &mut PhysicsState) { - let step_time = Instant::now().elapsed().as_secs_f64(); + let step_time = Instant::now(); let dt = physics.integration_parameters.dt; self.fluids_pipeline.step( &physics.gravity, @@ -340,7 +340,7 @@ impl TestbedPlugin for FluidsTestbedPlugin { &mut physics.bodies, ); - self.step_time = Instant::now().elapsed().as_secs_f64() - step_time; + self.step_time = step_time.elapsed().as_secs_f64(); } fn draw(