1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-12 08:05:18 +02: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
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
--------------------------------------------------------------------------------