mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-12 16:15:20 +02:00
Handle 0 vectors in vector.normalize()
This commit is contained in:
@@ -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)
|
||||||
|
Reference in New Issue
Block a user