Skip to content

Commit

Permalink
Add example to output a debugdump (#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz authored Sep 13, 2024
1 parent 8d10abc commit 5e91c6c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions bevy_rapier2d/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ approx = "0.5.1"
glam = { version = "0.27", features = ["approx"] }
bevy-inspector-egui = "0.25.1"
bevy_egui = "0.28.0"
bevy_mod_debugdump = "0.11"

[package.metadata.docs.rs]
# Enable all the features when building the docs on docs.rs
Expand Down
33 changes: 33 additions & 0 deletions bevy_rapier2d/examples/debugdump2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//! Example using bevy_mod_debugdump to output a graph of systems execution order.
//! run with:
//! `cargo run --example debugdump2 > dump.dot && dot -Tsvg dump.dot > dump.svg`

use bevy::prelude::*;
use bevy_mod_debugdump::{schedule_graph, schedule_graph_dot};
use bevy_rapier2d::prelude::*;

fn main() {
let mut app = App::new();
app.add_plugins((
DefaultPlugins,
RapierPhysicsPlugin::<NoUserData>::pixels_per_meter(100.0),
RapierDebugRenderPlugin::default(),
));

let mut debugdump_settings = schedule_graph::Settings::default();
// Filter out some less relevant systems.
debugdump_settings.include_system =
Some(Box::new(|system: &(dyn System<In = (), Out = ()>)| {
if system.name().starts_with("bevy_pbr")
|| system.name().starts_with("bevy_render")
|| system.name().starts_with("bevy_gizmos")
|| system.name().starts_with("bevy_winit")
|| system.name().starts_with("bevy_sprite")
{
return false;
}
true
}));
let dot = schedule_graph_dot(&mut app, PostUpdate, &debugdump_settings);
println!("{dot}");
}

0 comments on commit 5e91c6c

Please sign in to comment.