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`.
This commit is contained in:
Bruno BELANYI 2020-03-17 22:47:30 +01:00
parent d6f5f29a2a
commit 197e8104e0

View file

@ -27,6 +27,18 @@ impl LightAggregate {
spots,
}
}
pub fn ambient_lights_iter(&self) -> impl Iterator<Item = &'_ dyn Light> {
self.ambients.iter().map(|l| l as &dyn Light)
}
pub fn spatial_lights_iter(&self) -> impl Iterator<Item = &'_ dyn SpatialLight> {
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 {