diff options
Diffstat (limited to 'racer-tracer/src/geometry.rs')
| -rw-r--r-- | racer-tracer/src/geometry.rs | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/racer-tracer/src/geometry.rs b/racer-tracer/src/geometry.rs index 8d86353..1cc7e28 100644 --- a/racer-tracer/src/geometry.rs +++ b/racer-tracer/src/geometry.rs @@ -1,5 +1,8 @@ pub mod sphere; +use std::sync::Arc; + +use crate::material::Material; use crate::ray::Ray; use crate::vec3::Vec3; @@ -8,17 +11,17 @@ pub struct HitRecord { pub normal: Vec3, pub t: f64, pub front_face: bool, - pub color: Vec3, + pub material: Arc<Box<dyn Material + Send + Sync>>, } impl HitRecord { - fn new(point: Vec3, t: f64, color: Vec3) -> Self { + fn new(point: Vec3, t: f64, material: Arc<Box<dyn Material + Send + Sync>>) -> Self { Self { point, normal: Vec3::default(), t, front_face: true, - color, + material, } } @@ -32,18 +35,6 @@ impl HitRecord { } } -impl Default for HitRecord { - fn default() -> Self { - HitRecord { - point: Vec3::default(), - normal: Vec3::default(), - t: 0.0, - front_face: true, - color: Vec3::default(), - } - } -} - pub trait Hittable { //pub trait Hittable { fn hit(&self, ray: &Ray, t_min: f64, t_max: f64) -> Option<HitRecord>; |
