From a6302805d19273c95278c8d792ffbd9b2633fe20 Mon Sep 17 00:00:00 2001 From: Sakarias Johansson Date: Thu, 12 Jan 2023 21:09:43 +0100 Subject: =?UTF-8?q?=F0=9F=96=8C=EF=B8=8F=20Add=20materials?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- racer-tracer/src/geometry.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'racer-tracer/src/geometry.rs') 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>, } impl HitRecord { - fn new(point: Vec3, t: f64, color: Vec3) -> Self { + fn new(point: Vec3, t: f64, material: Arc>) -> 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; -- cgit v1.2.3