1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-16 18:01:40 +00:00

Optimize vector length calculations (#11549)

This commit is contained in:
Lean Rada 2021-08-28 02:22:35 +08:00 committed by GitHub
parent a7188bd6f5
commit d36dca3aba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 10 deletions

View file

@ -209,14 +209,7 @@ end
--------------------------------------------------------------------------------
function math.hypot(x, y)
local t
x = math.abs(x)
y = math.abs(y)
t = math.min(x, y)
x = math.max(x, y)
if x == 0 then return 0 end
t = t / x
return x * math.sqrt(1 + t * t)
return math.sqrt(x * x + y * y)
end
--------------------------------------------------------------------------------