diff --git a/KeepersCompound.Lightmapper/PotentiallyVisibleSet.cs b/KeepersCompound.Lightmapper/PotentiallyVisibleSet.cs index 514530d..5ea39a4 100644 --- a/KeepersCompound.Lightmapper/PotentiallyVisibleSet.cs +++ b/KeepersCompound.Lightmapper/PotentiallyVisibleSet.cs @@ -163,7 +163,7 @@ public class PotentiallyVisibleSet var validTarget = false; foreach (var v in target.Poly.Vertices) { - if (MathUtils.DistanceFromPlane(sourcePlane, v) < -MathUtils.Epsilon) + if (MathUtils.DistanceFromNormalizedPlane(sourcePlane, v) < -MathUtils.Epsilon) { validTarget = true; break; @@ -178,7 +178,7 @@ public class PotentiallyVisibleSet validTarget = false; foreach (var v in source.Poly.Vertices) { - if (MathUtils.DistanceFromPlane(targetPlane, v) > MathUtils.Epsilon) + if (MathUtils.DistanceFromNormalizedPlane(targetPlane, v) > MathUtils.Epsilon) { validTarget = true; break; diff --git a/KeepersCompound.Lightmapper/Utils.cs b/KeepersCompound.Lightmapper/Utils.cs index c3b8e29..5739aad 100644 --- a/KeepersCompound.Lightmapper/Utils.cs +++ b/KeepersCompound.Lightmapper/Utils.cs @@ -93,6 +93,11 @@ public static class MathUtils return (Vector3.Dot(plane.Normal, point) + plane.D) / plane.Normal.Length(); } + public static float DistanceFromNormalizedPlane(Plane plane, Vector3 point) + { + return Vector3.Dot(plane.Normal, point) + plane.D; + } + public static bool IsCoplanar(Plane p0, Plane p1) { var m = p0.D / p1.D;