summaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-04-24 19:28:05 +0200
committerHampusM <hampus@hampusmat.com>2024-04-24 19:28:05 +0200
commit77a061f73309c596e464ebb4fa787a23c62199e6 (patch)
tree00a5079af1e918e3e94111fa16eb696638ca6c3f /engine
parentf54b51c13ca0a647afbaef7c25f9ac3650be1c50 (diff)
fix: prevent panic when light source is also rendered
Diffstat (limited to 'engine')
-rw-r--r--engine/src/renderer/mod.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/engine/src/renderer/mod.rs b/engine/src/renderer/mod.rs
index cb7066f..5125da8 100644
--- a/engine/src/renderer/mod.rs
+++ b/engine/src/renderer/mod.rs
@@ -110,7 +110,12 @@ fn render(
return;
};
- let light_source = light_source_query.iter().next();
+ // TODO: Maybe find a way to not clone here? Cloning here is needed since a light
+ // source transform can be in both the object query and the light source query
+ let light_source = light_source_query
+ .iter()
+ .next()
+ .map(|(light_source, transform)| (light_source.clone(), transform.clone()));
let GlObjects {
shader_programs: gl_shader_programs,
@@ -137,7 +142,7 @@ fn render(
light_source
.as_ref()
.map(|(light_source, light_source_transform)| {
- (&**light_source, &**light_source_transform)
+ (light_source, light_source_transform)
}),
&camera,
);