From c25ca37bae08f7adafb27995af7337b458c62956 Mon Sep 17 00:00:00 2001 From: Joy <51241057+maniwani@users.noreply.github.com> Date: Sat, 20 Aug 2022 12:45:24 -0700 Subject: [PATCH] add global time scaling and global time pausing Co-Authored-By: ira --- .../src/frame_time_diagnostics_plugin.rs | 7 +- .../src/log_diagnostics_plugin.rs | 4 +- crates/bevy_time/src/time.rs | 636 ++++++++++++++++-- examples/2d/text2d.rs | 8 +- examples/3d/load_gltf.rs | 2 +- examples/3d/skybox.rs | 6 +- examples/3d/spotlight.rs | 9 +- examples/3d/transparency_3d.rs | 2 +- examples/3d/update_gltf_scene.rs | 4 +- examples/animation/custom_skinned_mesh.rs | 6 +- examples/animation/gltf_skinned_mesh.rs | 6 +- examples/audio/audio_control.rs | 2 +- examples/ecs/component_change_detection.rs | 4 +- examples/ecs/fixed_timestep.rs | 30 +- examples/ecs/hierarchy.rs | 4 +- examples/ecs/removal_detection.rs | 2 +- examples/ecs/state.rs | 2 +- examples/ecs/system_sets.rs | 2 +- examples/games/alien_cake_addict.rs | 5 +- examples/scene/scene.rs | 2 +- examples/shader/animate_shader.rs | 6 +- examples/tools/scene_viewer.rs | 2 +- examples/ui/text.rs | 2 +- examples/window/window_settings.rs | 2 +- 24 files changed, 625 insertions(+), 130 deletions(-) diff --git a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs index 9075cd4284d034..b07a69fc27e55d 100644 --- a/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs @@ -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); } } diff --git a/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs index 947b780725d3f2..26226dc036bcc4 100644 --- a/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/log_diagnostics_plugin.rs @@ -85,7 +85,7 @@ impl LogDiagnosticsPlugin { time: Res