Skip to content

Commit

Permalink
Fix frame count being a float (bevyengine#4493)
Browse files Browse the repository at this point in the history
Original reasoning: bevyengine#678 (comment)

That reasoning doesn't seem valid IMO since eventually +1 will do nothing. Using an integer is more intuitive and will wrap around which is probably better than getting stuck.
  • Loading branch information
SUPERCILEX authored and exjam committed May 22, 2022
1 parent d32557f commit ced9d2e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crates/bevy_diagnostic/src/frame_time_diagnostics_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use bevy_ecs::system::{Res, ResMut};
pub struct FrameTimeDiagnosticsPlugin;

pub struct FrameTimeDiagnosticsState {
frame_count: f64,
frame_count: u64,
}

impl Plugin for FrameTimeDiagnosticsPlugin {
fn build(&self, app: &mut bevy_app::App) {
app.add_startup_system(Self::setup_system)
.insert_resource(FrameTimeDiagnosticsState { frame_count: 0.0 })
.insert_resource(FrameTimeDiagnosticsState { frame_count: 0 })
.add_system(Self::diagnostic_system);
}
}
Expand All @@ -37,8 +37,8 @@ impl FrameTimeDiagnosticsPlugin {
time: Res<Time>,
mut state: ResMut<FrameTimeDiagnosticsState>,
) {
state.frame_count += 1.0;
diagnostics.add_measurement(Self::FRAME_COUNT, state.frame_count);
state.frame_count = state.frame_count.wrapping_add(1);
diagnostics.add_measurement(Self::FRAME_COUNT, state.frame_count as f64);

if time.delta_seconds_f64() == 0.0 {
return;
Expand Down

0 comments on commit ced9d2e

Please sign in to comment.