mirror of
https://github.com/moparisthebest/minetest
synced 2025-01-10 13:18:17 -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
|
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…
Reference in New Issue
Block a user