From 3bc9f6f924ad39ff6d20699aec45bc9cfb84a4cf Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Sat, 17 Jul 2021 15:07:14 -0700 Subject: [PATCH] world: add default empty World constructor. --- rtchallenge/src/lib.rs | 1 + rtchallenge/src/lights.rs | 1 + rtchallenge/src/world.rs | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 rtchallenge/src/world.rs diff --git a/rtchallenge/src/lib.rs b/rtchallenge/src/lib.rs index f3df8d7..f1a8623 100644 --- a/rtchallenge/src/lib.rs +++ b/rtchallenge/src/lib.rs @@ -6,6 +6,7 @@ pub mod matrices; pub mod rays; pub mod spheres; pub mod tuples; +pub mod world; /// Value considered close enough for PartialEq implementations. pub const EPSILON: f32 = 0.00001; diff --git a/rtchallenge/src/lights.rs b/rtchallenge/src/lights.rs index 456dca1..187e3b6 100644 --- a/rtchallenge/src/lights.rs +++ b/rtchallenge/src/lights.rs @@ -1,5 +1,6 @@ use crate::tuples::{Color, Tuple}; +#[derive(Debug, PartialEq)] pub struct PointLight { pub position: Tuple, pub intensity: Color, diff --git a/rtchallenge/src/world.rs b/rtchallenge/src/world.rs new file mode 100644 index 0000000..dce199b --- /dev/null +++ b/rtchallenge/src/world.rs @@ -0,0 +1,19 @@ +use crate::{lights::PointLight, spheres::Sphere}; + +/// World holds all drawable objects and the light(s) that illuminate them. +/// +/// # Examples +/// ``` +/// use rtchallenge::world::World; +/// +/// let w = World::default(); +/// assert!(w.objects.is_empty()); +/// assert_eq!(w.light, None); +/// ``` + +#[derive(Debug, Default)] +pub struct World { + // TODO(wathiede): make this a list of abstract Light traits. + pub light: Option, + pub objects: Vec, +}