From da1cac1bff7c77971aa28dfb98b11d834d43d599 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Fri, 10 Nov 2023 18:10:00 -0500 Subject: [PATCH] Implement removing a light from the scene --- src/render/light/mod.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/render/light/mod.rs b/src/render/light/mod.rs index c1c51fe..8f084d1 100644 --- a/src/render/light/mod.rs +++ b/src/render/light/mod.rs @@ -71,12 +71,17 @@ impl LightBuffer { } } - pub fn remove_light(&mut self, queue: &wgpu::Queue, entity: edict::EntityId) { - todo!() // TODO - } + /// Remove a caster from the buffer, returns true if it was removed. + pub fn remove_light(&mut self, lights_buffer: &mut [U; MAX_LIGHT_COUNT], entity: edict::EntityId) -> bool { + if let Some(removed_idx) = self.used_indexes.remove(&entity) { + self.dead_indexes.push_back(removed_idx); + self.current_count -= 1; + lights_buffer[removed_idx] = U::default(); - pub fn prune_dead_lights(&mut self, queue: &wgpu::Queue, entity: edict::EntityId) { - todo!() // TODO + true + } else { + false + } } }