mirror of
https://github.com/moparisthebest/minetest
synced 2024-12-22 23:58:48 -05:00
Handle 0 vectors in vector.normalize()
This commit is contained in:
parent
39ab22070e
commit
07715b1b6a
@ -31,7 +31,12 @@ function vector.length(v)
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
function vector.round(v)
|
||||
|
Loading…
Reference in New Issue
Block a user