mirror of
https://github.com/bevyengine/bevy
synced 2024-11-26 22:50:19 +00:00
Fix frame count being a float (#4493)
Original reasoning: https://github.com/bevyengine/bevy/pull/678#issuecomment-930602773 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.
This commit is contained in:
parent
84c783b100
commit
1648c89b64
1 changed files with 4 additions and 4 deletions
|
@ -8,13 +8,13 @@ use bevy_ecs::system::{Res, ResMut};
|
||||||
pub struct FrameTimeDiagnosticsPlugin;
|
pub struct FrameTimeDiagnosticsPlugin;
|
||||||
|
|
||||||
pub struct FrameTimeDiagnosticsState {
|
pub struct FrameTimeDiagnosticsState {
|
||||||
frame_count: f64,
|
frame_count: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Plugin for FrameTimeDiagnosticsPlugin {
|
impl Plugin for FrameTimeDiagnosticsPlugin {
|
||||||
fn build(&self, app: &mut bevy_app::App) {
|
fn build(&self, app: &mut bevy_app::App) {
|
||||||
app.add_startup_system(Self::setup_system)
|
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);
|
.add_system(Self::diagnostic_system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,8 @@ impl FrameTimeDiagnosticsPlugin {
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
mut state: ResMut<FrameTimeDiagnosticsState>,
|
mut state: ResMut<FrameTimeDiagnosticsState>,
|
||||||
) {
|
) {
|
||||||
state.frame_count += 1.0;
|
state.frame_count = state.frame_count.wrapping_add(1);
|
||||||
diagnostics.add_measurement(Self::FRAME_COUNT, state.frame_count);
|
diagnostics.add_measurement(Self::FRAME_COUNT, state.frame_count as f64);
|
||||||
|
|
||||||
if time.delta_seconds_f64() == 0.0 {
|
if time.delta_seconds_f64() == 0.0 {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue