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
pub mod shapelist;
pub mod sphere;


use std::sync::Arc;

use crate::{
    HitData,
    Ray
};


/// Basic trait that every scene object must implement.
pub trait Shape: Sync + Send + 'static {
    /// Wraps the object implementing this trait with Atomic Rc pointer.
    ///
    /// Used for multithreading.
    fn into_arc(self) -> Arc<dyn Shape>
        where
            Self: Shape + Sized + 'static {
        Arc::new(self)
    }

    fn hit(&self, r: &Ray, t_min: f32, t_max: f32) -> Option<HitData>;
}