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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
use na::Real;
use math::Isometry;
use shape::{Plane, Shape};
use query::Proximity;
use query::proximity_internal;
use pipeline::narrow_phase::{ProximityDetector, ProximityDispatcher};
#[derive(Clone)]
pub struct PlaneSupportMapProximityDetector {
proximity: Proximity,
}
impl PlaneSupportMapProximityDetector {
#[inline]
pub fn new() -> PlaneSupportMapProximityDetector {
PlaneSupportMapProximityDetector {
proximity: Proximity::Disjoint,
}
}
}
#[derive(Clone)]
pub struct SupportMapPlaneProximityDetector {
subdetector: PlaneSupportMapProximityDetector,
}
impl SupportMapPlaneProximityDetector {
#[inline]
pub fn new() -> SupportMapPlaneProximityDetector {
SupportMapPlaneProximityDetector {
subdetector: PlaneSupportMapProximityDetector::new(),
}
}
}
impl<N: Real> ProximityDetector<N> for PlaneSupportMapProximityDetector {
#[inline]
fn update(
&mut self,
_: &ProximityDispatcher<N>,
ma: &Isometry<N>,
plane: &Shape<N>,
mb: &Isometry<N>,
b: &Shape<N>,
margin: N,
) -> bool {
if let (Some(p), Some(sm)) = (plane.as_shape::<Plane<N>>(), b.as_support_map()) {
self.proximity = proximity_internal::plane_against_support_map(ma, p, mb, sm, margin);
true
} else {
false
}
}
#[inline]
fn proximity(&self) -> Proximity {
self.proximity
}
}
impl<N: Real> ProximityDetector<N> for SupportMapPlaneProximityDetector {
#[inline]
fn update(
&mut self,
disp: &ProximityDispatcher<N>,
ma: &Isometry<N>,
a: &Shape<N>,
mb: &Isometry<N>,
b: &Shape<N>,
margin: N,
) -> bool {
self.subdetector.update(disp, mb, b, ma, a, margin)
}
#[inline]
fn proximity(&self) -> Proximity {
ProximityDetector::<N>::proximity(&self.subdetector)
}
}