nphysics2d/counters/
collision_detection_counters.rs1use crate::counters::Timer;
2use std::fmt::{Display, Formatter, Result};
3
4#[derive(Default, Clone, Copy)]
6pub struct CollisionDetectionCounters {
7 pub ncontact_pairs: usize,
9 pub broad_phase_time: Timer,
11 pub narrow_phase_time: Timer,
13}
14
15impl CollisionDetectionCounters {
16 pub fn new() -> Self {
18 CollisionDetectionCounters {
19 ncontact_pairs: 0,
20 broad_phase_time: Timer::new(),
21 narrow_phase_time: Timer::new(),
22 }
23 }
24}
25
26impl Display for CollisionDetectionCounters {
27 fn fmt(&self, f: &mut Formatter) -> Result {
28 writeln!(f, "Number of contact pairs: {}", self.ncontact_pairs)?;
29 writeln!(f, "Broad-phase time: {}", self.broad_phase_time)?;
30 writeln!(f, "Narrow-phase time: {}", self.narrow_phase_time)
31 }
32}