pub struct World {
shapes: Vec<Box<dyn RayIntersection>>,
}
Expand description
A class holding a list of shapes
(e.g. Plane
, Sphere
).
You can add shapes to a world using add
.
Typically, you call ray_intersection
to check whether
a light ray intersects any of the shapes in the world.
Fields§
§shapes: Vec<Box<dyn RayIntersection>>
A std::vec::Vec
of std::boxed::Box
-ed shapes
that implement RayIntersection
trait
(vector of traits).
Implementations§
source§impl World
impl World
sourcepub fn add(&mut self, shape: Box<dyn RayIntersection>)
pub fn add(&mut self, shape: Box<dyn RayIntersection>)
Append a new boxed shape to this World
.
sourcepub fn ray_intersection(&self, ray: Ray) -> Option<HitRecord>
pub fn ray_intersection(&self, ray: Ray) -> Option<HitRecord>
Determine whether a ray intersects any of the objects in this World
.
Return HitRecord
wrapped inside std::option::Option
.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for World
impl Send for World
impl Sync for World
impl Unpin for World
impl !UnwindSafe for World
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more