diff --git a/KeepersCompound.Lightmapper/Program.cs b/KeepersCompound.Lightmapper/Program.cs index 77a46bf..13d3136 100644 --- a/KeepersCompound.Lightmapper/Program.cs +++ b/KeepersCompound.Lightmapper/Program.cs @@ -1,4 +1,4 @@ -using System.Numerics; +using System.Numerics; using KeepersCompound.LGS.Database; using KeepersCompound.LGS.Database.Chunks; using TinyEmbree; @@ -257,6 +257,15 @@ class Program continue; } + // If there aren't *any* points on the plane that are in range of the light + // then none of the lightmap points will be so we can discard. + // The more compact a map is the less effective this is + var planeDist = MathUtils.DistanceFromPlane(plane, light.position); + if (planeDist > light.radius) + { + continue; + } + for (var y = 0; y < lightmap.Height; y++) { for (var x = 0; x < lightmap.Width; x++)