diff options
author | Julian T <julian@jtle.dk> | 2021-08-02 15:21:59 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2021-08-02 15:21:59 +0200 |
commit | 351d9132c0b2c54dfa9f50bfe328d25ccf059cea (patch) | |
tree | c2b9401c6484f1ba5354de4ea5dc6f58b2a214cd /src/world/shapes | |
parent | 13e018067631a7401df5b232f95f3d1f7a0cd75c (diff) |
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.
Diffstat (limited to 'src/world/shapes')
-rw-r--r-- | src/world/shapes/sphere.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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<DynHittable> for Sphere { + fn into(self) -> DynHittable { + DynHittable::new(Box::new(self)) + } +} + #[cfg(test)] mod tests { use super::*; |