pub struct LightManager {
pub ambient_color: Color,
pub ambient_intensity: f32,
/* private fields */
}Expand description
Manages up to 64 simultaneous lights with spatial grid queries.
Fields§
§ambient_color: ColorAmbient light applied everywhere.
ambient_intensity: f32Implementations§
Source§impl LightManager
impl LightManager
pub fn new() -> Self
pub fn with_grid_cell_size(self, size: f32) -> Self
Sourcepub fn add(&mut self, light: Light) -> Option<LightId>
pub fn add(&mut self, light: Light) -> Option<LightId>
Add a light, returning its ID. Returns None if at max capacity.
Sourcepub fn add_point(&mut self, light: PointLight) -> Option<LightId>
pub fn add_point(&mut self, light: PointLight) -> Option<LightId>
Add a point light.
Sourcepub fn add_directional(&mut self, light: DirectionalLight) -> Option<LightId>
pub fn add_directional(&mut self, light: DirectionalLight) -> Option<LightId>
Add a directional light.
Sourcepub fn add_emissive(&mut self, light: EmissiveGlyph) -> Option<LightId>
pub fn add_emissive(&mut self, light: EmissiveGlyph) -> Option<LightId>
Add an emissive glyph light.
Sourcepub fn add_animated(&mut self, light: AnimatedLight) -> Option<LightId>
pub fn add_animated(&mut self, light: AnimatedLight) -> Option<LightId>
Add an animated light.
Sourcepub fn add_ies(&mut self, light: IESProfile) -> Option<LightId>
pub fn add_ies(&mut self, light: IESProfile) -> Option<LightId>
Add an IES profile light.
Sourcepub fn get_mut(&mut self, id: LightId) -> Option<&mut Light>
pub fn get_mut(&mut self, id: LightId) -> Option<&mut Light>
Get a mutable reference to a light by ID.
Sourcepub fn rebuild_grid(&mut self)
pub fn rebuild_grid(&mut self)
Force a rebuild of the spatial grid.
Sourcepub fn lights_at(&mut self, pos: Vec3) -> Vec<LightId>
pub fn lights_at(&mut self, pos: Vec3) -> Vec<LightId>
Query which lights affect a given world position.
Sourcepub fn lights_in_aabb(&mut self, min: Vec3, max: Vec3) -> Vec<LightId>
pub fn lights_in_aabb(&mut self, min: Vec3, max: Vec3) -> Vec<LightId>
Query which lights affect a given AABB.
Sourcepub fn irradiance_at(&mut self, point: Vec3, normal: Vec3) -> Color
pub fn irradiance_at(&mut self, point: Vec3, normal: Vec3) -> Color
Compute total irradiance at a world position from all affecting lights.
Sourcepub fn active_count(&self) -> usize
pub fn active_count(&self) -> usize
Get the number of active lights.
Sourcepub fn total_count(&self) -> usize
pub fn total_count(&self) -> usize
Get the total number of lights (active + disabled).
Sourcepub fn most_important_lights(
&mut self,
point: Vec3,
normal: Vec3,
count: usize,
) -> Vec<LightId>
pub fn most_important_lights( &mut self, point: Vec3, normal: Vec3, count: usize, ) -> Vec<LightId>
Get the N most important lights for a given point (sorted by contribution).
Sourcepub fn set_enabled(&mut self, id: LightId, enabled: bool)
pub fn set_enabled(&mut self, id: LightId, enabled: bool)
Enable or disable a light.
Sourcepub fn set_position(&mut self, id: LightId, position: Vec3)
pub fn set_position(&mut self, id: LightId, position: Vec3)
Set the position of a positional light.
Sourcepub fn shadow_casters(&self) -> Vec<(LightId, &Light)>
pub fn shadow_casters(&self) -> Vec<(LightId, &Light)>
Get shadow-casting lights for the shadow system.
Sourcepub fn enabled_lights(&self) -> Vec<(LightId, &Light)>
pub fn enabled_lights(&self) -> Vec<(LightId, &Light)>
Get all enabled lights as a flat list (useful for GPU upload).
Sourcepub fn stats(&self) -> LightManagerStats
pub fn stats(&self) -> LightManagerStats
Get statistics about the light manager.
Trait Implementations§
Source§impl Debug for LightManager
impl Debug for LightManager
Auto Trait Implementations§
impl Freeze for LightManager
impl RefUnwindSafe for LightManager
impl Send for LightManager
impl Sync for LightManager
impl Unpin for LightManager
impl UnsafeUnpin for LightManager
impl UnwindSafe for LightManager
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.