From 07715b1b6adbdaeaa3f72591297ad59b443a0d9c Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Sun, 7 Jul 2013 02:02:45 -0400 Subject: [PATCH] Handle 0 vectors in vector.normalize() --- builtin/vector.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builtin/vector.lua b/builtin/vector.lua index f534471c..839f139c 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) -- 2.30.2