Handle 0 vectors in vector.normalize()

This commit is contained in:
ShadowNinja 2013-07-07 02:02:45 -04:00 committed by kwolekr
parent 39ab22070e
commit 07715b1b6a
1 changed files with 6 additions and 1 deletions

View File

@ -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)