ncollide3d/query/closest_points/
closest_points.rs

1use crate::math::Point;
2use na::RealField;
3use std::mem;
4
5/// Closest points information.
6#[derive(Debug, PartialEq, Clone, Copy)]
7#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
8pub enum ClosestPoints<N: RealField + Copy> {
9    /// The two objects are intersecting.
10    Intersecting,
11    /// The two objects are non-intersecting but closer than a given user-defined distance.
12    WithinMargin(Point<N>, Point<N>),
13    /// The two objects are non-intersecting and further than a given user-defined distance.
14    Disjoint,
15}
16
17impl<N: RealField + Copy> ClosestPoints<N> {
18    /// Swaps the two points.
19    pub fn flip(&mut self) {
20        if let ClosestPoints::WithinMargin(ref mut p1, ref mut p2) = *self {
21            mem::swap(p1, p2)
22        }
23    }
24}