Expand description
Diagnostics support for tracking physics timers and counters. Useful for profiling and debugging.
§Overview
Each physics plugin such as NarrowPhasePlugin
and SolverPlugin
is responsible
for implementing its own diagnostics resource using the PhysicsDiagnostics
trait
and registering it using AppDiagnosticsExt::register_physics_diagnostics
.
If the bevy_diagnostic
feature is enabled and the [PhysicsDiagnosticsPlugin
] is added to the app,
these diagnostics will also be automatically written to the DiagnosticsStore
resource.
If the diagnostic_ui
feature is enabled and the PhysicsDiagnosticsUiPlugin
is added to the app,
a debug UI will also be available for displaying these diagnostics in real-time.
§Example
use avian3d::prelude::*;
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins((
DefaultPlugins,
PhysicsPlugins::default(),
// Add the `PhysicsDiagnosticsPlugin` to write physics diagnostics
// to the `DiagnosticsStore` resource in `bevy_diagnostic`.
// Requires the `bevy_diagnostic` feature.
PhysicsDiagnosticsPlugin,
// Add the `PhysicsDiagnosticsUiPlugin` to display physics diagnostics
// in a debug UI. Requires the `diagnostic_ui` feature.
PhysicsDiagnosticsUiPlugin,
))
// ...your other plugins, systems and resources
.run();
}
§Supported Diagnostics
The following diagnostics are available but not added by default:
- [
PhysicsTotalDiagnostics
]: Total physics timers and counters. PhysicsEntityDiagnostics
: Physics entity counters.
Additionally, physics plugins may implement their own diagnostics that are enabled by default. These include:
CollisionDiagnostics
: Diagnostics for collision detection.SolverDiagnostics
: Diagnostics for the physics solver.SpatialQueryDiagnostics
: Diagnostics for spatial queries.PhysicsPickingDiagnostics
: Diagnostics for physics picking.
Structs§
- Diagnostics for physics entity counts.
Enums§
- A system set for physics diagnostics.
Traits§
- An extension trait for registering physics diagnostics in an
App
. - A trait for resources storing timers and counters for physics diagnostics.