Use faster plane distance calculation
This commit is contained in:
parent
e48393b856
commit
54655254b9
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue