diff --git a/source/Jitter/Collision/GJKCollide.cs b/source/Jitter/Collision/GJKCollide.cs index 044842d6..23b1c9f6 100644 --- a/source/Jitter/Collision/GJKCollide.cs +++ b/source/Jitter/Collision/GJKCollide.cs @@ -346,6 +346,12 @@ public static bool Raycast(ISupportMappable support, ref JMatrix orientation, re else { lambda = lambda - VdotW / VdotR; + if (lambda > 1) + { + //If we've gone beyond where the ray can reach, there's obviously no hit. + simplexSolverPool.GiveBack(simplexSolver); + return false; + } JVector.Multiply(ref r, lambda, out x); JVector.Add(ref origin, ref x, out x); JVector.Subtract(ref x, ref p, out w);