Skip to content

Commit

Permalink
add global time scaling and global time pausing
Browse files Browse the repository at this point in the history
Co-Authored-By: ira <JustTheCoolDude@gmail.com>
  • Loading branch information
maniwani and tim-blackbird committed Oct 20, 2022
1 parent 681c9c6 commit c25ca37
Show file tree
Hide file tree
Showing 24 changed files with 625 additions and 130 deletions.
7 changes: 4 additions & 3 deletions crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ impl FrameTimeDiagnosticsPlugin {
state.frame_count as f64
});

if time.delta_seconds_f64() == 0.0 {
let delta_seconds = time.raw_delta_seconds_f64();
if delta_seconds == 0.0 {
return;
}

diagnostics.add_measurement(Self::FRAME_TIME, || time.delta_seconds_f64() * 1000.);
diagnostics.add_measurement(Self::FRAME_TIME, || delta_seconds * 1000.0);

diagnostics.add_measurement(Self::FPS, || 1.0 / time.delta_seconds_f64());
diagnostics.add_measurement(Self::FPS, || 1.0 / delta_seconds);
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_diagnostic/src/log_diagnostics_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl LogDiagnosticsPlugin {
time: Res<Time>,
diagnostics: Res<Diagnostics>,
) {
if state.timer.tick(time.delta()).finished() {
if state.timer.tick(time.raw_delta()).finished() {
if let Some(ref filter) = state.filter {
for diagnostic in filter.iter().flat_map(|id| {
diagnostics
Expand All @@ -110,7 +110,7 @@ impl LogDiagnosticsPlugin {
time: Res<Time>,
diagnostics: Res<Diagnostics>,
) {
if state.timer.tick(time.delta()).finished() {
if state.timer.tick(time.raw_delta()).finished() {
if let Some(ref filter) = state.filter {
for diagnostic in filter.iter().flat_map(|id| {
diagnostics
Expand Down
Loading

0 comments on commit c25ca37

Please sign in to comment.