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::{impl_diagnostic_paths, PhysicsDiagnostics};
10
11/// Diagnostics for spatial queries.
12#[derive(Resource, Debug, Default, Reflect)]
13#[reflect(Resource, Debug)]
14pub struct SpatialQueryDiagnostics {
15    /// Time spent updating the [`SpatialQueryPipeline`](super::SpatialQueryPipeline).
16    pub update_pipeline: Duration,
17    /// Time spent updating [`RayCaster`](super::RayCaster) hits.
18    pub update_ray_casters: Duration,
19    /// Time spent updating [`ShapeCaster`](super::ShapeCaster) hits.
20    pub update_shape_casters: Duration,
21}
22
23impl PhysicsDiagnostics for SpatialQueryDiagnostics {
24    fn timer_paths(&self) -> Vec<(&'static DiagnosticPath, Duration)> {
25        vec![
26            (Self::UPDATE_PIPELINE, self.update_pipeline),
27            (Self::UPDATE_RAY_CASTERS, self.update_ray_casters),
28            (Self::UPDATE_SHAPE_CASTERS, self.update_shape_casters),
29        ]
30    }
31}
32
33impl_diagnostic_paths! {
34    impl SpatialQueryDiagnostics {
35        UPDATE_PIPELINE: "avian/spatial_query/update_pipeline",
36        UPDATE_RAY_CASTERS: "avian/spatial_query/update_ray_casters",
37        UPDATE_SHAPE_CASTERS: "avian/spatial_query/update_shape_casters",
38    }
39}