ft (wip): 10: dielectrics

This commit is contained in:
2026-04-16 15:38:01 +02:00
parent b756cc394a
commit 1920376e34
6 changed files with 71 additions and 7 deletions

View File

@@ -11,15 +11,17 @@ pub struct Hit {
p: Vec3,
n: Vec3,
mat: Arc<dyn Material>,
front_face: bool,
}
impl Hit {
pub fn new(t: f32, p: Vec3, n: Vec3, mat: Arc<dyn Material>) -> Self {
pub fn new(t: f32, p: Vec3, n: Vec3, mat: Arc<dyn Material>, front_face: bool) -> Self {
Self {
t: t,
p: p,
n: n,
n: if front_face { n } else { -n },
mat: mat,
front_face: front_face,
}
}
@@ -39,6 +41,10 @@ impl Hit {
self.mat.clone()
}
pub fn front_face(&self) -> bool {
self.front_face
}
pub fn hit_list<T: Hittable>(hittables: &Vec<T>, r: &Ray) -> Option<Hit> {
let mut closest: Option<Hit> = None;
for hittable in hittables {