Skip to content

Commit

Permalink
address PR feedbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Sep 6, 2024
1 parent 46ccba0 commit 16ccae5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/counters/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use web_time::Instant;
pub struct Timer {
enabled: bool,
time: f64,
start: Option<f64>,
start: Option<Instant>,
}

impl Timer {
Expand Down Expand Up @@ -38,15 +38,15 @@ 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());
}
}

/// Pause the 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;
}
Expand All @@ -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());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/integrations/rapier/harness_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/integrations/rapier/testbed_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down

0 comments on commit 16ccae5

Please sign in to comment.