From 4f2acd53e948ceb03738da33a80ec4aefe29af5a Mon Sep 17 00:00:00 2001 From: Deyan Dobromirov Date: Sun, 26 Dec 2021 13:12:11 +0200 Subject: [PATCH] Fixed: Check when ray length is zero ( never negative ) --- lua/stargate/shared/tracelines.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/stargate/shared/tracelines.lua b/lua/stargate/shared/tracelines.lua index 60aed63c..470d55a4 100644 --- a/lua/stargate/shared/tracelines.lua +++ b/lua/stargate/shared/tracelines.lua @@ -128,7 +128,7 @@ function StarGate.Trace:HitSphere(rorg, rdir, rlen, spos, srad, blen) local rlen = (tonumber(rlen) or rdir:Length()) local rdir = rdir:GetNormalized(); rdir:Mul(rlen) local equa = rdir:LengthSqr() -- Ray length is zero - if(equa < 0) then return nil end -- No intersection + if(equa == 0) then return nil end -- No intersection local equr = Vector(rorg) equr:Sub(spos) -- Calculate norm local equb, equc = 2 * rdir:Dot(equr), (equr:LengthSqr() - srad^2) local equd = (equb ^ 2 - 4 * equa * equc) -- Check imaginary roots