Replace epsilon usages with constant
This commit is contained in:
parent
5957b5b53f
commit
2c74cc5594
|
@ -4,6 +4,8 @@ namespace KeepersCompound.Lightmapper;
|
||||||
|
|
||||||
public static class MathUtils
|
public static class MathUtils
|
||||||
{
|
{
|
||||||
|
public const float Epsilon = 0.001f;
|
||||||
|
|
||||||
public readonly struct Aabb
|
public readonly struct Aabb
|
||||||
{
|
{
|
||||||
public readonly Vector3 Min;
|
public readonly Vector3 Min;
|
||||||
|
@ -77,9 +79,9 @@ public static class MathUtils
|
||||||
var offset = p2d - a;
|
var offset = p2d - a;
|
||||||
var norm = Vector2.Normalize(new Vector2(-segment.Y, segment.X));
|
var norm = Vector2.Normalize(new Vector2(-segment.Y, segment.X));
|
||||||
var side = Vector2.Dot(norm, offset);
|
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;
|
inside = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -322,7 +322,7 @@ class Program
|
||||||
|
|
||||||
// cheeky epsilon
|
// cheeky epsilon
|
||||||
// TODO: Some pixels aren't hitting and I'm not sure why
|
// 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)
|
if (hit)
|
||||||
{
|
{
|
||||||
// Calculate light strength at a given point. As far as I can tell
|
// Calculate light strength at a given point. As far as I can tell
|
||||||
|
|
Loading…
Reference in New Issue