rapier3d/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 pub fn reset(&mut self) {
27 self.ncontact_pairs = 0;
28 self.broad_phase_time.reset();
29 self.narrow_phase_time.reset();
30 }
31}
32
33impl Display for CollisionDetectionCounters {
34 fn fmt(&self, f: &mut Formatter) -> Result {
35 writeln!(f, "Number of contact pairs: {}", self.ncontact_pairs)?;
36 writeln!(f, "Broad-phase time: {}", self.broad_phase_time)?;
37 writeln!(f, "Narrow-phase time: {}", self.narrow_phase_time)
38 }
39}