Skip to content

Commit

Permalink
Fixed: Check when ray length is zero ( never negative )
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdvideo1234 committed Dec 26, 2021
1 parent e629b6c commit 4f2acd5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lua/stargate/shared/tracelines.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f2acd5

Please sign in to comment.