Skip to content

Commit

Permalink
fix: Make adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lubba-64 committed Aug 26, 2024
1 parent 4d56e81 commit 7ae3861
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions crates/bevy_app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,14 @@ pub mod prelude {
#[cfg(feature = "fixed_time")]
pub use crate::main_schedule::{
FixedFirst, FixedLast, FixedPostUpdate, FixedPreUpdate, FixedUpdate, RunFixedMainLoop,
RunFixedMainLoopSystem,
};
#[doc(hidden)]
pub use crate::{
app::{App, AppExit},
main_schedule::{
First, Last, Main, PostStartup, PostUpdate, PreStartup, PreUpdate,
RunFixedMainLoopSystem, SpawnScene, Startup, Update,
First, Last, Main, PostStartup, PostUpdate, PreStartup, PreUpdate, SpawnScene, Startup,
Update,
},
sub_app::SubApp,
Plugin, PluginGroup,
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_app/src/main_schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ impl FixedMain {
///
/// Note that in contrast to most other Bevy schedules, systems added directly to
/// [`RunFixedMainLoop`] will *not* be parallelized between each other.
#[cfg(feature = "fixed_time")]
#[derive(Debug, Hash, PartialEq, Eq, Copy, Clone, SystemSet)]
pub enum RunFixedMainLoopSystem {
/// Runs before the fixed update logic.
Expand Down
3 changes: 3 additions & 0 deletions crates/bevy_time/src/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ use crate::virt::Virtual;
/// frame. Any [`overstep()`](Time::overstep) present in the accumulator will be
/// processed according to the new [`timestep()`](Time::timestep) value.
#[derive(Debug, Copy, Clone)]
#[cfg(feature = "fixed_time")]
#[cfg_attr(feature = "bevy_reflect", derive(Reflect))]
pub struct Fixed {
timestep: Duration,
overstep: Duration,
}

#[cfg(feature = "fixed_time")]
impl Time<Fixed> {
/// Corresponds to 64 Hz.
const DEFAULT_TIMESTEP: Duration = Duration::from_micros(15625);
Expand Down Expand Up @@ -229,6 +231,7 @@ impl Time<Fixed> {
}
}

#[cfg(feature = "fixed_time")]
impl Default for Fixed {
fn default() -> Self {
Self {
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ mod tests {
counter.0 += 1;
}

#[cfg(feature = "fixed_time")]
fn report_time(
mut frame_count: Local<u64>,
virtual_time: Res<Time<Virtual>>,
Expand All @@ -214,6 +215,7 @@ mod tests {
}

#[test]
#[cfg(feature = "fixed_time")]
fn fixed_main_schedule_should_run_with_time_plugin_enabled() {
// Set the time step to just over half the fixed update timestep
// This way, it will have not accumulated enough time to run the fixed update after one update
Expand All @@ -222,7 +224,6 @@ mod tests {
let time_step = fixed_update_timestep / 2 + Duration::from_millis(1);

let mut app = App::new();
#[cfg(feature = "fixed_time")]
app.add_systems(FixedUpdate, count_fixed_updates);

app.add_plugins(TimePlugin)
Expand Down Expand Up @@ -272,6 +273,7 @@ mod tests {
}

#[test]
#[cfg(feature = "fixed_time")]
fn events_get_dropped_regression_test_11528() -> Result<(), impl Error> {
let (tx1, rx1) = std::sync::mpsc::channel();
let (tx2, rx2) = std::sync::mpsc::channel();
Expand Down Expand Up @@ -313,6 +315,7 @@ mod tests {
}

#[test]
#[cfg(feature = "fixed_time")]
fn event_update_should_wait_for_fixed_main() {
// Set the time step to just over half the fixed update timestep
// This way, it will have not accumulated enough time to run the fixed update after one update
Expand Down

0 comments on commit 7ae3861

Please sign in to comment.