Skip to main content

collider_query/
contact.rs

1//! Contact properties and collision detection between shapes.
2
3use collider_shape::shape::Shape;
4use nalgebra::{Isometry3, Point3};
5
6/// Description of a contact.
7pub struct Contact {
8    /// Point of contact for the first shape.
9    pub point1: Point3<f32>,
10    /// Point of contact for the second shape.
11    pub point2: Point3<f32>,
12}
13
14/// Computes the contact properties between two shapes.
15/// This function returns `None` if the shapes are not in contact.
16///
17/// # Arguments
18///
19/// * `shape1` - The first shape.
20/// * `pos1` - The position and rotation of the first shape.
21/// * `shape2` - The second shape.
22/// * `pos2` - The position and rotation of the second shape.
23pub fn contact<S1: Shape, S2: Shape>(
24    _shape1: S1,
25    _pos1: Isometry3<f32>,
26    _shape2: S2,
27    _pos2: Isometry3<f32>,
28) -> Option<Contact> {
29    unimplemented!()
30}
31
32#[cfg(test)]
33mod test {
34    use collider_shape::{Cuboid, Sphere};
35
36    use super::*;
37
38    #[ignore]
39    #[test]
40    fn test_contact() {
41        let shape1 = Cuboid::new(nalgebra::Vector3::new(1.0, 1.0, 1.0));
42        let pos1 = Isometry3::identity();
43        let shape2 = Sphere::new(1.0);
44        let pos2 = Isometry3::identity();
45
46        let contact = contact(shape1, pos1, shape2, pos2);
47        assert!(contact.is_none());
48    }
49}