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
use crate::math::{Isometry, Point};
use crate::pipeline::narrow_phase::{ProximityDetector, ProximityDispatcher};
use crate::query::{self, Proximity};
use crate::shape::{Ball, Shape};
use na::RealField;
pub struct BallBallProximityDetector {}
impl Clone for BallBallProximityDetector {
fn clone(&self) -> BallBallProximityDetector {
BallBallProximityDetector {}
}
}
impl BallBallProximityDetector {
#[inline]
pub fn new() -> BallBallProximityDetector {
BallBallProximityDetector {}
}
}
impl<N: RealField> ProximityDetector<N> for BallBallProximityDetector {
fn update(
&mut self,
_: &dyn ProximityDispatcher<N>,
ma: &Isometry<N>,
a: &dyn Shape<N>,
mb: &Isometry<N>,
b: &dyn Shape<N>,
margin: N,
) -> Option<Proximity> {
let a = a.as_shape::<Ball<N>>()?;
let b = b.as_shape::<Ball<N>>()?;
Some(query::proximity_ball_ball(
&Point::from(ma.translation.vector),
a,
&Point::from(mb.translation.vector),
b,
margin,
))
}
}