Add empty cornell box with light and flipped normals.
This commit is contained in:
30
rtiow/src/flip_normals.rs
Normal file
30
rtiow/src/flip_normals.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
use aabb::AABB;
|
||||
use hitable::Hit;
|
||||
use hitable::HitRecord;
|
||||
use ray::Ray;
|
||||
|
||||
pub struct FlipNormals {
|
||||
hitable: Box<Hit>,
|
||||
}
|
||||
|
||||
impl FlipNormals {
|
||||
pub fn new(hitable: Box<Hit>) -> FlipNormals {
|
||||
FlipNormals { hitable }
|
||||
}
|
||||
}
|
||||
|
||||
impl Hit for FlipNormals {
|
||||
fn hit(&self, r: Ray, t_min: f32, t_max: f32) -> Option<HitRecord> {
|
||||
if let Some(rec) = self.hitable.hit(r, t_min, t_max) {
|
||||
return Some(HitRecord {
|
||||
normal: -rec.normal,
|
||||
..rec
|
||||
});
|
||||
};
|
||||
None
|
||||
}
|
||||
|
||||
fn bounding_box(&self, t_min: f32, t_max: f32) -> Option<AABB> {
|
||||
self.hitable.bounding_box(t_min, t_max)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user