latest update

This commit is contained in:
2023-01-30 17:18:16 +01:00
parent 899e8b7228
commit b764470c77
4 changed files with 34 additions and 12 deletions

View File

@@ -1,14 +1,18 @@
use crate::hittable::*;
use std::rc::Rc;
use crate::{hittable::*, material};
use crate::material::Material;
use crate::vec3::*;
pub struct Sphere {
center: Point3,
radius: f64
radius: f64,
mat_ptr: Rc<Material>,
}
impl Sphere {
pub fn new(center: Point3, radius: f64) -> Self {
Sphere {center, radius}
pub fn new(center: Point3, radius: f64, mat_ptr: Rc<Material>) -> Self {
Sphere {center, radius, mat_ptr}
}
}
@@ -36,6 +40,7 @@ impl Hittable for Sphere {
rec.p = r.at(rec.t);
let outward_normal = (rec.p - self.center) / self.radius;
rec.set_face_normal(r, &outward_normal);
rec.mat_ptr = self.mat_ptr;
return true;
}