diff options
author | Julian T <julian@jtle.dk> | 2021-07-31 14:02:52 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-07-31 14:02:52 +0200 |
commit | cee9bcf4a2c8ffbfe6487f7886b2247eaba1c92c (patch) | |
tree | 7fd405d9a3f6351d6341706fba50a8616d6c3a84 /src/world/mod.rs | |
parent | 55044e56304c8484b8ff52f362ab1c66c9c5ca93 (diff) |
Better documentation and cleanup
Diffstat (limited to 'src/world/mod.rs')
-rw-r--r-- | src/world/mod.rs | 7 |
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 { |