diff --git a/KeepersCompound.Lightmapper/MathUtils.cs b/KeepersCompound.Lightmapper/MathUtils.cs index 64dbb85..d0ade09 100644 --- a/KeepersCompound.Lightmapper/MathUtils.cs +++ b/KeepersCompound.Lightmapper/MathUtils.cs @@ -4,6 +4,8 @@ namespace KeepersCompound.Lightmapper; public static class MathUtils { + public const float Epsilon = 0.001f; + public readonly struct Aabb { public readonly Vector3 Min; @@ -77,9 +79,9 @@ public static class MathUtils var offset = p2d - a; var norm = Vector2.Normalize(new Vector2(-segment.Y, segment.X)); var side = Vector2.Dot(norm, offset); - if (side >= -0.001) + if (side >= -Epsilon) { - p2d -= norm * (side + 0.0015f); + p2d -= norm * (side + 2 * Epsilon); inside = false; } } diff --git a/KeepersCompound.Lightmapper/Program.cs b/KeepersCompound.Lightmapper/Program.cs index 3f6fbb2..074775e 100644 --- a/KeepersCompound.Lightmapper/Program.cs +++ b/KeepersCompound.Lightmapper/Program.cs @@ -322,7 +322,7 @@ class Program // cheeky epsilon // TODO: Some pixels aren't hitting and I'm not sure why - var hit = hitResult && Math.Abs(hitResult.Distance - direction.Length()) < 0.001; + var hit = hitResult && Math.Abs(hitResult.Distance - direction.Length()) < MathUtils.Epsilon; if (hit) { // Calculate light strength at a given point. As far as I can tell