From 351d9132c0b2c54dfa9f50bfe328d25ccf059cea Mon Sep 17 00:00:00 2001 From: Julian T Date: Mon, 2 Aug 2021 15:21:59 +0200 Subject: Move back to dynamic dispatch for object.shape This will allow more general nesting, with the performance penalty of dynamic dispatching. This is implemented with the DynHittable for convenience. --- src/world/shapes/sphere.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/world/shapes') diff --git a/src/world/shapes/sphere.rs b/src/world/shapes/sphere.rs index 1df9c35..fc2cfe2 100644 --- a/src/world/shapes/sphere.rs +++ b/src/world/shapes/sphere.rs @@ -3,7 +3,7 @@ //! Spheres are relatively easy to calculate intersections between use crate::{Float, NEAR_ZERO}; use crate::core::{Ray, Vector3f, Bound3f}; -use crate::world::{Hittable, Intersection}; +use crate::world::{Hittable, DynHittable, Intersection}; pub struct Sphere { radius: Float, @@ -79,6 +79,12 @@ impl Hittable for Sphere { } } +impl Into for Sphere { + fn into(self) -> DynHittable { + DynHittable::new(Box::new(self)) + } +} + #[cfg(test)] mod tests { use super::*; -- cgit v1.2.3