From 197e8104e047d7cc7628529d114a0c0b1fb48680 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Tue, 17 Mar 2020 22:47:30 +0100 Subject: [PATCH] library: render: light_aggregate: add *_iter You can iterate over the two types of lights in the aggregate: the ones implementing `SpatialLight`, and the ones that are only `Light`. --- src/render/light_aggregate.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/render/light_aggregate.rs b/src/render/light_aggregate.rs index 2407c24..aecb6e9 100644 --- a/src/render/light_aggregate.rs +++ b/src/render/light_aggregate.rs @@ -27,6 +27,18 @@ impl LightAggregate { spots, } } + + pub fn ambient_lights_iter(&self) -> impl Iterator { + self.ambients.iter().map(|l| l as &dyn Light) + } + + pub fn spatial_lights_iter(&self) -> impl Iterator { + self.directionals + .iter() + .map(|l| l as &dyn SpatialLight) + .chain(self.points.iter().map(|l| l as &dyn SpatialLight)) + .chain(self.spots.iter().map(|l| l as &dyn SpatialLight)) + } } impl Default for LightAggregate {