latest
This commit is contained in:
@@ -1,22 +1,20 @@
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::{hittable::*, material};
|
||||
use crate::hittable::*;
|
||||
use crate::material::Material;
|
||||
use crate::vec3::*;
|
||||
|
||||
pub struct Sphere {
|
||||
pub struct Sphere<'a> {
|
||||
center: Point3,
|
||||
radius: f64,
|
||||
mat_ptr: Rc<Material>,
|
||||
mat_ptr: &'a dyn Material,
|
||||
}
|
||||
|
||||
impl Sphere {
|
||||
pub fn new(center: Point3, radius: f64, mat_ptr: Rc<Material>) -> Self {
|
||||
impl Sphere<'_> {
|
||||
pub fn new<T: Material>(center: Point3, radius: f64, mat_ptr: &T) -> Self {
|
||||
Sphere {center, radius, mat_ptr}
|
||||
}
|
||||
}
|
||||
|
||||
impl Hittable for Sphere {
|
||||
impl Hittable for Sphere<'_> {
|
||||
fn hit(&mut self, r: &crate::ray::Ray, t_min: f64, t_max: f64, rec: &mut HitRecord) -> bool {
|
||||
let oc = r.origin() - self.center;
|
||||
let a = r.direction().length_squared();
|
||||
|
||||
Reference in New Issue
Block a user