aboutsummaryrefslogtreecommitdiff
path: root/src/world/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/world/mod.rs')
-rw-r--r--src/world/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/world/mod.rs b/src/world/mod.rs
index 53d8ad3..3a09522 100644
--- a/src/world/mod.rs
+++ b/src/world/mod.rs
@@ -27,7 +27,12 @@ impl Object {
impl Hittable for Object {
fn intersect(&self, ray: &Ray) -> Option<Intersection> {
- self.shape.intersect(ray).map(|mut i| {i.m = Some(self.mat.as_ref()); i})
+ if let Some(mut inter) = self.shape.intersect(ray) {
+ inter.add_material_if_none(self.mat.as_ref());
+ Some(inter)
+ } else {
+ None
+ }
}
fn bounding_box(&self) -> Bound3f {