This commit is contained in:
2023-02-01 22:30:20 +01:00
parent 0a70a1e1de
commit 560b2b1196
5 changed files with 21 additions and 27 deletions

View File

@@ -1,21 +1,19 @@
use std::rc::Rc;
use crate::material::Material;
use crate::ray::*;
use crate::vec3::*;
#[derive(Clone)]
pub struct HitRecord {
pub struct HitRecord<'a> {
pub p: Point3,
pub normal: Vec3,
pub mat_ptr: Rc<Material>,
pub mat_ptr: &'a dyn Material,
pub t: f64,
pub front_face: bool,
}
impl HitRecord {
pub fn new_empty() -> Self {
HitRecord { p: Point3::new(0.0, 0.0, 0.0), normal: Vec3::new(0.0, 0.0, 0.0), t: 0.0, front_face: false, mat_ptr: Rc::new(Material { }) }
impl HitRecord<'_> {
pub fn new_empty<T: Material>(material: &T) -> Self {
HitRecord { p: Point3::new(0.0, 0.0, 0.0), normal: Vec3::new(0.0, 0.0, 0.0), t: 0.0, front_face: false, mat_ptr: material }
}
pub fn set_face_normal(&mut self, r: &Ray, outward_normal: &Vec3) {