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
use num_traits::{Bounded, Zero}; #[derive(Debug, Clone, PartialEq)] pub struct Intersection<T> { pub edge: usize, pub distance: T, pub point: [T; 2], pub normal: [T; 2], } impl<T> From<(usize, T, [T; 2], [T; 2])> for Intersection<T> { #[inline(always)] fn from((edge, distance, point, normal): (usize, T, [T; 2], [T; 2])) -> Self { Intersection { edge: edge, distance: distance, point: point, normal: normal, } } } impl<T> Intersection<T> where T: Zero + Bounded, { #[inline(always)] pub fn new() -> Self { Intersection { edge: 0, distance: T::max_value(), point: [T::zero(), T::zero()], normal: [T::zero(), T::zero()], } } }