From 852cd65c6a88b3961edc4390d7374883f202da85 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 17 Mar 2020 20:40:12 +0100 Subject: [PATCH] library: render: add LightAggregate implementation --- src/render/light_aggregate.rs | 60 +++++++++++++++++++++++++++++++++++ src/render/mod.rs | 3 ++ 2 files changed, 63 insertions(+) create mode 100644 src/render/light_aggregate.rs diff --git a/src/render/light_aggregate.rs b/src/render/light_aggregate.rs new file mode 100644 index 0000000..c45cd4b --- /dev/null +++ b/src/render/light_aggregate.rs @@ -0,0 +1,60 @@ +use crate::light; + +#[derive(Debug, PartialEq)] +pub struct LightAggregate { + ambient_lights: Vec, + directional_lights: Vec, + point_lights: Vec, + spot_lights: Vec, +} + +impl LightAggregate { + pub fn empty() -> Self { + LightAggregate::new(vec![], vec![], vec![], vec![]) + } + + pub fn new( + ambient_lights: Vec, + directional_lights: Vec, + point_lights: Vec, + spot_lights: Vec, + ) -> Self { + LightAggregate { + ambient_lights, + directional_lights, + point_lights, + spot_lights, + } + } +} + +impl Default for LightAggregate { + fn default() -> Self { + LightAggregate::empty() + } +} + +#[cfg(test)] +mod test { + use super::*; + + #[test] + fn empty_works() { + let lights = LightAggregate::empty(); + assert_eq!( + lights, + LightAggregate { + ambient_lights: vec![], + directional_lights: vec![], + point_lights: vec![], + spot_lights: vec![], + } + ) + } + + #[test] + fn default_is_empty() { + let lights = ::default(); + assert_eq!(lights, LightAggregate::empty()) + } +} diff --git a/src/render/mod.rs b/src/render/mod.rs index 099ed81..175aa06 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -1,2 +1,5 @@ +pub mod light_aggregate; +pub use light_aggregate::*; + pub mod object; pub use object::*;