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
//! Collision primitives

pub use self::capsule::Capsule;
pub use self::circle::Circle;
pub use self::cuboid::Cuboid;
pub use self::cylinder::Cylinder;
pub use self::particle::*;
pub use self::polygon::ConvexPolygon;
pub use self::polyhedron::ConvexPolyhedron;
pub use self::primitive2::Primitive2;
pub use self::primitive3::Primitive3;
pub use self::rectangle::Rectangle;
pub use self::sphere::Sphere;

mod circle;
mod rectangle;
mod polygon;
mod sphere;
mod cylinder;
mod capsule;
mod cuboid;
mod polyhedron;
mod particle;
mod primitive2;
mod primitive3;

pub(crate) mod util;

use cgmath::{EuclideanSpace, Transform};

use prelude::*;

impl<B, P> HasBound for (P, B)
where
    P: Primitive,
    B: Bound,
{
    type Bound = B;

    fn bound(&self) -> &Self::Bound {
        &self.1
    }
}

impl<B, P> Primitive for (P, B)
where
    P: Primitive,
    B: Bound,
{
    type Point = P::Point;

    fn support_point<T>(
        &self,
        direction: &<Self::Point as EuclideanSpace>::Diff,
        transform: &T,
    ) -> Self::Point
    where
        T: Transform<Self::Point>,
    {
        self.0.support_point(direction, transform)
    }
}