Skip to content

Commit

Permalink
Bevy 0.13 (#52)
Browse files Browse the repository at this point in the history
* Updates for Bevy main (will become 0.13)

* bump to bevy 0.13

* bump version

* update readme

* fix docs

---------

Co-authored-by: Arend van Beelen jr <[email protected]>
  • Loading branch information
aevyrie and arendjr authored Feb 18, 2024
1 parent 6479002 commit 71dfd5a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_framepace"
version = "0.14.1"
version = "0.15.0"
edition = "2021"
resolver = "2"
description = "Frame pacing and frame limiting for Bevy"
Expand All @@ -11,7 +11,7 @@ documentation = "https://docs.rs/bevy_framepace"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy = { version = "0.12", default-features = false, features = [
bevy = { version = "0.13", default-features = false, features = [
"bevy_render",
"bevy_winit",
] }
Expand All @@ -22,7 +22,7 @@ default = ["framepace_debug", "bevy/x11"]
framepace_debug = []

[dev-dependencies]
bevy = { version = "0.12", default-features = false, features = [
bevy = { version = "0.13", default-features = false, features = [
"bevy_gizmos",
"bevy_text",
"bevy_ui",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ I intend to track the `main` branch of Bevy. PRs supporting this are welcome!

| bevy | bevy_framepace |
| ---- | ------------------- |
| 0.13 | 0.15 |
| 0.12 | 0.14 |
| 0.11 | 0.13 |
| 0.10 | 0.12 |
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct EnableText;

fn toggle_plugin(
mut settings: ResMut<bevy_framepace::FramepaceSettings>,
input: Res<Input<KeyCode>>,
input: Res<ButtonInput<KeyCode>>,
) {
if input.just_pressed(KeyCode::Space) {
use bevy_framepace::Limiter;
Expand Down
28 changes: 11 additions & 17 deletions src/debug.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Adds diagnostic logging and a cursor for debugging.
use bevy::{
diagnostic::{Diagnostic, DiagnosticId, Diagnostics, RegisterDiagnostic},
diagnostic::{Diagnostic, DiagnosticPath, Diagnostics, RegisterDiagnostic},
prelude::*,
};

Expand All @@ -12,24 +12,18 @@ impl Plugin for DiagnosticsPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Update, Self::diagnostic_system);

app.register_diagnostic(
Diagnostic::new(Self::FRAMEPACE_FRAMETIME, "framepace::frametime", 128)
.with_suffix("ms"),
);
app.register_diagnostic(
Diagnostic::new(Self::FRAMEPACE_OVERSLEEP, "framepace::oversleep", 128)
.with_suffix("µs"),
);
app.register_diagnostic(Diagnostic::new(Self::FRAMEPACE_FRAMETIME).with_suffix("ms"));
app.register_diagnostic(Diagnostic::new(Self::FRAMEPACE_OVERSLEEP).with_suffix("µs"));
}
}

impl DiagnosticsPlugin {
/// [`DiagnosticId`] for the frametime
pub const FRAMEPACE_FRAMETIME: DiagnosticId =
DiagnosticId::from_u128(8021378406439507683279787892187089153);
/// [`DiagnosticId`] for failures to meet frame time target
pub const FRAMEPACE_OVERSLEEP: DiagnosticId =
DiagnosticId::from_u128(978023490268634078905367093342937);
/// [`DiagnosticPath`] for the frametime
pub const FRAMEPACE_FRAMETIME: DiagnosticPath =
DiagnosticPath::const_new("framepace/frametime");
/// [`DiagnosticPath`] for failures to meet frame time target
pub const FRAMEPACE_OVERSLEEP: DiagnosticPath =
DiagnosticPath::const_new("framepace/oversleep");

/// Updates diagnostic data from measurements
pub fn diagnostic_system(
Expand All @@ -44,7 +38,7 @@ impl DiagnosticsPlugin {
let frametime_millis = stats.frametime.try_lock().unwrap().as_secs_f64() * 1_000_f64;
let error_micros = stats.oversleep.try_lock().unwrap().as_secs_f64() * 1_000_000_f64;

diagnostics.add_measurement(Self::FRAMEPACE_FRAMETIME, || frametime_millis);
diagnostics.add_measurement(Self::FRAMEPACE_OVERSLEEP, || error_micros);
diagnostics.add_measurement(&Self::FRAMEPACE_FRAMETIME, || frametime_millis);
diagnostics.add_measurement(&Self::FRAMEPACE_OVERSLEEP, || error_micros);
}
}

0 comments on commit 71dfd5a

Please sign in to comment.