From cee9bcf4a2c8ffbfe6487f7886b2247eaba1c92c Mon Sep 17 00:00:00 2001 From: Julian T Date: Sat, 31 Jul 2021 14:02:52 +0200 Subject: Better documentation and cleanup --- src/world/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/world/mod.rs') 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 { - 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 { -- cgit v1.2.3