From 5beba9f9f48246bf1afbc58724c34819ed3140ac Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Sat, 11 Jan 2025 17:57:52 +0000 Subject: [PATCH] Handle dynamic lights correctly --- KeepersCompound.LGS/Database/Chunks/WorldRep.cs | 4 ++-- KeepersCompound.Lightmapper/Light.cs | 1 + KeepersCompound.Lightmapper/LightMapper.cs | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/KeepersCompound.LGS/Database/Chunks/WorldRep.cs b/KeepersCompound.LGS/Database/Chunks/WorldRep.cs index 917d88d..e65bff8 100644 --- a/KeepersCompound.LGS/Database/Chunks/WorldRep.cs +++ b/KeepersCompound.LGS/Database/Chunks/WorldRep.cs @@ -690,13 +690,13 @@ public class WorldRep : IChunk if (dynamicLight) { DynamicLightCount++; + Lights.Add(data); } else { + Lights.Insert(LightCount, data); LightCount++; } - - Lights.Add(data); } } diff --git a/KeepersCompound.Lightmapper/Light.cs b/KeepersCompound.Lightmapper/Light.cs index 6585027..7c77426 100644 --- a/KeepersCompound.Lightmapper/Light.cs +++ b/KeepersCompound.Lightmapper/Light.cs @@ -21,6 +21,7 @@ public class Light public int ObjId; public int LightTableIndex; public bool Anim; + public bool Dynamic; public WorldRep.LightTable.LightData ToLightData(float lightScale) { diff --git a/KeepersCompound.Lightmapper/LightMapper.cs b/KeepersCompound.Lightmapper/LightMapper.cs index 8457745..479e8ac 100644 --- a/KeepersCompound.Lightmapper/LightMapper.cs +++ b/KeepersCompound.Lightmapper/LightMapper.cs @@ -293,7 +293,7 @@ public class LightMapper } } - if (propAnimLight != null && !propAnimLight.Dynamic) + if (propAnimLight != null) { var lightIndex = lightTable.LightCount; propAnimLight.LightTableLightIndex = (ushort)lightIndex; @@ -310,6 +310,7 @@ public class LightMapper ObjId = id, LightTableIndex = propAnimLight.LightTableLightIndex, Anim = true, + Dynamic = propAnimLight.Dynamic, SpotlightInnerAngle = -1f, }; @@ -324,7 +325,7 @@ public class LightMapper light.ApplyTransforms(vhotLightPos, vhotLightDir, translate, rotate, scale); _lights.Add(light); - lightTable.AddLight(light.ToLightData(32.0f)); + lightTable.AddLight(light.ToLightData(32.0f), propAnimLight.Dynamic); } if (propLight != null && propLight.Brightness != 0) @@ -486,7 +487,7 @@ public class LightMapper for (var j = 0; j < _lights.Count; j++) { var light = _lights[j]; - if (!MathUtils.Intersects(new MathUtils.Sphere(light.Position, light.Radius), cellAabb)) + if (light.Dynamic || !MathUtils.Intersects(new MathUtils.Sphere(light.Position, light.Radius), cellAabb)) { continue; }