ft (wip): 10: dielectrics
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user