diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-05-17 22:12:00 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2022-05-17 22:12:00 +0200 |
commit | 21df26984da91143c15587f5a03c98d68c3adc4e (patch) | |
tree | aaa707a628ad331f67890023dffe1b4f60dd01d3 /builtin/common/vector.lua | |
parent | b09fc5de5cdb021f43ad32b7e3f50dc75c0bc622 (diff) | |
parent | eabf05758e3ba5f6f4bb1b8d1d1f02179b84e410 (diff) | |
download | dragonfireclient-21df26984da91143c15587f5a03c98d68c3adc4e.tar.xz |
Merge branch 'master' of https://github.com/minetest/minetest
Diffstat (limited to 'builtin/common/vector.lua')
-rw-r--r-- | builtin/common/vector.lua | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/builtin/common/vector.lua b/builtin/common/vector.lua index 02fc1bdee..a08472e32 100644 --- a/builtin/common/vector.lua +++ b/builtin/common/vector.lua @@ -6,10 +6,8 @@ Note: The vector.*-functions must be able to accept old vectors that had no meta -- localize functions local setmetatable = setmetatable -vector = {} - -local metatable = {} -vector.metatable = metatable +-- vector.metatable is set by C++. +local metatable = vector.metatable local xyz = {"x", "y", "z"} @@ -61,7 +59,7 @@ function vector.from_string(s, init) if not (x and y and z) then return nil end - return {x = x, y = y, z = z}, np + return fast_new(x, y, z), np end function vector.to_string(v) @@ -112,6 +110,14 @@ function vector.apply(v, func) ) end +function vector.combine(a, b, func) + return fast_new( + func(a.x, b.x), + func(a.y, b.y), + func(a.z, b.z) + ) +end + function vector.distance(a, b) local x = a.x - b.x local y = a.y - b.y |