diff options
| author | Sébastien Crozet <developer@crozet.re> | 2020-08-25 22:10:25 +0200 |
|---|---|---|
| committer | Sébastien Crozet <developer@crozet.re> | 2020-08-25 22:10:25 +0200 |
| commit | 754a48b7ff6d8c58b1ee08651e60112900b60455 (patch) | |
| tree | 7d777a6c003f1f5d8f8d24f533f35a95a88957fe /src/counters/collision_detection_counters.rs | |
| download | rapier-754a48b7ff6d8c58b1ee08651e60112900b60455.tar.gz rapier-754a48b7ff6d8c58b1ee08651e60112900b60455.tar.bz2 rapier-754a48b7ff6d8c58b1ee08651e60112900b60455.zip | |
First public release of Rapier.v0.1.0
Diffstat (limited to 'src/counters/collision_detection_counters.rs')
| -rw-r--r-- | src/counters/collision_detection_counters.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/counters/collision_detection_counters.rs b/src/counters/collision_detection_counters.rs new file mode 100644 index 0000000..d164452 --- /dev/null +++ b/src/counters/collision_detection_counters.rs @@ -0,0 +1,32 @@ +use crate::counters::Timer; +use std::fmt::{Display, Formatter, Result}; + +/// Performance counters related to collision detection. +#[derive(Default, Clone, Copy)] +pub struct CollisionDetectionCounters { + /// Number of contact pairs detected. + pub ncontact_pairs: usize, + /// Time spent for the broad-phase of the collision detection. + pub broad_phase_time: Timer, + /// Time spent for the narrow-phase of the collision detection. + pub narrow_phase_time: Timer, +} + +impl CollisionDetectionCounters { + /// Creates a new counter initialized to zero. + pub fn new() -> Self { + CollisionDetectionCounters { + ncontact_pairs: 0, + broad_phase_time: Timer::new(), + narrow_phase_time: Timer::new(), + } + } +} + +impl Display for CollisionDetectionCounters { + fn fmt(&self, f: &mut Formatter) -> Result { + writeln!(f, "Number of contact pairs: {}", self.ncontact_pairs)?; + writeln!(f, "Broad-phase time: {}", self.broad_phase_time)?; + writeln!(f, "Narrow-phase time: {}", self.narrow_phase_time) + } +} |
