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
use na::{RealField, Unit};
use crate::math::{Isometry, Point, Vector};
use crate::shape::SupportMap;
pub struct ConstantOrigin;
impl<N: RealField> SupportMap<N> for ConstantOrigin {
#[inline]
fn support_point(&self, _: &Isometry<N>, _: &Vector<N>) -> Point<N> {
Point::origin()
}
#[inline]
fn support_point_toward(&self, _: &Isometry<N>, _: &Unit<Vector<N>>) -> Point<N> {
Point::origin()
}
}
pub struct DilatedShape<'a, N: RealField, S: ?Sized + SupportMap<N>> {
pub shape: &'a S,
pub radius: N,
}
impl<'a, N: RealField, S: ?Sized + SupportMap<N>> SupportMap<N> for DilatedShape<'a, N, S> {
#[inline]
fn support_point(&self, m: &Isometry<N>, dir: &Vector<N>) -> Point<N> {
self.support_point_toward(m, &Unit::new_normalize(*dir))
}
#[inline]
fn support_point_toward(&self, m: &Isometry<N>, dir: &Unit<Vector<N>>) -> Point<N> {
self.shape.support_point_toward(m, dir) + **dir * self.radius
}
}