avian3d/spatial_query/
diagnostics.rs

1use core::time::Duration;
2
3use bevy::{
4    diagnostic::DiagnosticPath,
5    prelude::{ReflectResource, Resource},
6    reflect::Reflect,
7};
8
9use crate::diagnostics::{PhysicsDiagnostics, impl_diagnostic_paths};
10
11/// Diagnostics for spatial queries.
12#[derive(Resource, Debug, Default, Reflect)]
13#[reflect(Resource, Debug)]
14pub struct SpatialQueryDiagnostics {
15    /// Time spent updating [`RayCaster`](super::RayCaster) hits.
16    pub update_ray_casters: Duration,
17    /// Time spent updating [`ShapeCaster`](super::ShapeCaster) hits.
18    pub update_shape_casters: Duration,
19}
20
21impl PhysicsDiagnostics for SpatialQueryDiagnostics {
22    fn timer_paths(&self) -> Vec<(&'static DiagnosticPath, Duration)> {
23        vec![
24            (Self::UPDATE_RAY_CASTERS, self.update_ray_casters),
25            (Self::UPDATE_SHAPE_CASTERS, self.update_shape_casters),
26        ]
27    }
28}
29
30impl_diagnostic_paths! {
31    impl SpatialQueryDiagnostics {
32        UPDATE_RAY_CASTERS: "avian/spatial_query/update_ray_casters",
33        UPDATE_SHAPE_CASTERS: "avian/spatial_query/update_shape_casters",
34    }
35}