mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Handle 0 vectors in vector.normalize()
This commit is contained in:
parent
39ab22070e
commit
07715b1b6a
1 changed files with 6 additions and 1 deletions
|
@ -31,7 +31,12 @@ function vector.length(v)
|
||||||
end
|
end
|
||||||
|
|
||||||
function vector.normalize(v)
|
function vector.normalize(v)
|
||||||
return vector.divide(v, vector.length(v))
|
local len = vector.length(v)
|
||||||
|
if len == 0 then
|
||||||
|
return vector.new()
|
||||||
|
else
|
||||||
|
return vector.divide(v, len)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function vector.round(v)
|
function vector.round(v)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue