From: ShadowNinja Date: Sun, 7 Jul 2013 06:02:45 +0000 (-0400) Subject: Handle 0 vectors in vector.normalize() X-Git-Tag: 0.4.8~341 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=07715b1b6adbdaeaa3f72591297ad59b443a0d9c;p=oweals%2Fminetest.git Handle 0 vectors in vector.normalize() --- diff --git a/builtin/vector.lua b/builtin/vector.lua index f534471c2..839f139ca 100644 --- a/builtin/vector.lua +++ b/builtin/vector.lua @@ -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)