diff options
| author | Sakarias Johansson <sakarias.johansson@goodbyekansas.com> | 2023-01-12 21:09:43 +0100 |
|---|---|---|
| committer | Sakarias Johansson <sakarias.johansson@goodbyekansas.com> | 2023-01-12 21:09:43 +0100 |
| commit | a6302805d19273c95278c8d792ffbd9b2633fe20 (patch) | |
| tree | 9e539215cce7ba2eed4f873c711282f9d40a2591 /racer-tracer/src/geometry.rs | |
| parent | bbecf67545c2bd6822b0680673aa850c5ddef9f3 (diff) | |
| download | racer-tracer-a6302805d19273c95278c8d792ffbd9b2633fe20.tar.gz racer-tracer-a6302805d19273c95278c8d792ffbd9b2633fe20.tar.xz racer-tracer-a6302805d19273c95278c8d792ffbd9b2633fe20.zip | |
🖌️ Add materials
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>; |
