Feat: Materials!

Got the enums to work. This match block is going to be absolutely
massive, but whatever. Current materials are Lambertian and Metal.
This commit is contained in:
2023-06-04 10:31:59 -05:00
parent d1bde8a1a8
commit 7926cd2b13
5 changed files with 125 additions and 28 deletions

View File

@@ -7,12 +7,10 @@ use crate::hittable::{
use crate::material::Material;
use crate::ray::Ray;
use std::rc::Rc;
pub struct Sphere{
pub center: Vec3,
pub radius: f32,
pub material: Option<Rc<dyn Material>>,
pub material: Option<Material>,
}
impl Hittable for Sphere {
@@ -39,7 +37,7 @@ impl Hittable for Sphere {
let mut record = HitRecord{
p: r.at(root),
normal: (r.at(root) - self.center) / self.radius,
material: self.material.clone(),
material: self.material,
t: root,
front_face: false,
};