1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use crate::bounding_volume::BoundingVolume;
use crate::partitioning::{VisitStatus, Visitor};
use na::RealField;
use std::marker::PhantomData;
pub struct BoundingVolumeInterferencesCollector<'a, N: 'a, T: 'a, BV: 'a> {
pub bv: &'a BV,
pub collector: &'a mut Vec<T>,
_point: PhantomData<N>,
}
impl<'a, N, T, BV> BoundingVolumeInterferencesCollector<'a, N, T, BV>
where
N: RealField,
BV: BoundingVolume<N>,
{
#[inline]
pub fn new(
bv: &'a BV,
buffer: &'a mut Vec<T>,
) -> BoundingVolumeInterferencesCollector<'a, N, T, BV> {
BoundingVolumeInterferencesCollector {
bv: bv,
collector: buffer,
_point: PhantomData,
}
}
}
impl<'a, N, T, BV> Visitor<T, BV> for BoundingVolumeInterferencesCollector<'a, N, T, BV>
where
N: RealField,
T: Clone,
BV: BoundingVolume<N>,
{
#[inline]
fn visit(&mut self, bv: &BV, t: Option<&T>) -> VisitStatus {
if bv.intersects(self.bv) {
if let Some(t) = t {
self.collector.push(t.clone())
}
VisitStatus::Continue
} else {
VisitStatus::Stop
}
}
}