projects
/
oweals
/
minetest.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
39ab220
)
Handle 0 vectors in vector.normalize()
author
ShadowNinja
<noreply@gmail.com>
Sun, 7 Jul 2013 06:02:45 +0000
(
02:02
-0400)
committer
kwolekr
<kwolekr@minetest.net>
Sun, 7 Jul 2013 06:29:09 +0000
(
02:29
-0400)
builtin/vector.lua
patch
|
blob
|
history
diff --git
a/builtin/vector.lua
b/builtin/vector.lua
index f534471c2c12f4bbdec28bf34e6125953aaebe52..839f139ca25a018314b0ca0224150974b9369b0e 100644
(file)
--- 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)