1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
//! Trace trait.

use crate::geom::{Ray, Side};

/// Trace trait implementation.
/// Types implementing this trait can be traced using 'Ray's.
pub trait Trace {
    /// Determine if a ray hit occurs.
    fn hit(&self, ray: &Ray) -> bool;

    /// Distance to the surface along the ray's line of travel.
    fn dist(&self, ray: &Ray) -> Option<f64>;

    /// Distance to the surface along the ray's line of travel and side of collision.
    fn dist_side(&self, ray: &Ray) -> Option<(f64, Side)>;
}