latest update
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user