From 3f78cacdd93036dbd51bae77d5d8e5430a0bc75f Mon Sep 17 00:00:00 2001 From: Julian T Date: Sat, 6 Mar 2021 16:15:26 +0100 Subject: Several changes to bounding boxes For instance removed support for shapes without a bounding box, such as planes --- src/world/shapes/sphere.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/world/shapes') diff --git a/src/world/shapes/sphere.rs b/src/world/shapes/sphere.rs index 55fc8b4..e3348de 100644 --- a/src/world/shapes/sphere.rs +++ b/src/world/shapes/sphere.rs @@ -57,19 +57,18 @@ impl Hittable for Sphere { /// # Examples /// /// ``` - /// use rendering::core::{Vector3f, Hittable}; - /// use rendering::world::shapes::Sphere; + /// use rendering::core::Vector3f; + /// use rendering::world::{Hittable, shapes::Sphere}; /// /// let sph = Sphere::new(1.0, Vector3f::new(0.0)); - /// let b = sph.bounding_box().unwrap(); + /// let b = sph.bounding_box(); /// /// assert!(b.min.x == -1.0 && b.min.y == -1.0 && b.min.z == -1.0); /// assert!(b.max.x == 1.0 && b.max.y == 1.0 && b.max.z == 1.0); - fn bounding_box(&self) -> Option { + fn bounding_box(&self) -> Bound3f { let offset = Vector3f::new(self.radius); - Some( - Bound3f::new(self.center - offset, self.center + offset) - ) + + Bound3f::new(self.center - offset, self.center + offset) } } -- cgit v1.2.3