From edd01952e79ec02e1e415407f30b61c1a995c044 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Tue, 24 Sep 2024 08:13:27 +0100 Subject: [PATCH] Discard planes that don't intersect with sphere --- KeepersCompound.Lightmapper/Program.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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++)