parry3d_f64/query/visitors/aabb_sets_interferences_collector.rs
1use crate::math::{Isometry, Matrix, Real};
2use alloc::vec::Vec;
3
4/// Spatial partitioning data structure visitor collecting interferences with a given bounding volume.
5pub struct AabbSetsInterferencesCollector<'a, T: 'a> {
6 /// The transform from the local-space of the second bounding volumes to the local space of the first.
7 pub ls_m2: &'a Isometry<Real>,
8 /// The absolute value of the rotation matrix representing `ls_m2.rotation`.
9 ///
10 /// Equals to `ls_m2.rotation.to_rotation.matrix().matrix().abs()`.
11 pub ls_m2_abs_rot: &'a Matrix<Real>,
12 /// A tolerance applied to the interference tests.
13 ///
14 /// Aabb pairs closer than `tolerance` will be reported as intersecting.
15 pub tolerance: Real,
16 /// The data contained by the nodes with bounding volumes intersecting `self.bv`.
17 pub collector: &'a mut Vec<(T, T)>,
18}
19
20impl<'a, T> AabbSetsInterferencesCollector<'a, T> {
21 /// Creates a new `AabbSetsInterferencesCollector`.
22 #[inline]
23 pub fn new(
24 tolerance: Real,
25 ls_m2: &'a Isometry<Real>,
26 ls_m2_abs_rot: &'a Matrix<Real>,
27 collector: &'a mut Vec<(T, T)>,
28 ) -> AabbSetsInterferencesCollector<'a, T> {
29 AabbSetsInterferencesCollector {
30 tolerance,
31 ls_m2,
32 ls_m2_abs_rot,
33 collector,
34 }
35 }
36}
37
38// impl<'a, T: Clone> SimultaneousVisitor<T, Aabb> for AabbSetsInterferencesCollector<'a, T> {
39// #[inline]
40// fn visit(
41// &mut self,
42// left_bv: &Aabb,
43// left_data: Option<&T>,
44// right_bv: &Aabb,
45// right_data: Option<&T>,
46// ) -> VisitStatus {
47// let ls_right_bv = Aabb::from_half_extents(
48// self.ls_m2 * right_bv.center(),
49// self.ls_m2_abs_rot * right_bv.half_extents() + Vector::repeat(self.tolerance),
50// );
51//
52// if left_bv.intersects(&ls_right_bv) {
53// if let (Some(a), Some(b)) = (left_data, right_data) {
54// self.collector.push((a.clone(), b.clone()))
55// }
56//
57// VisitStatus::Continue
58// } else {
59// VisitStatus::Stop
60// }
61// }
62// }