mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-22 06:04:35 +00:00
made vector metamethods not do inplace modifications (was completely unsafe and i can't believe i missed it on review :D sorry folks)
This commit is contained in:
parent
3d03d3238a
commit
ef4ef69b0f
14
vec2.lua
14
vec2.lua
@ -455,28 +455,28 @@ end
|
||||
|
||||
-- meta functions for mathmatical operations
|
||||
function vec2.__add(a, b)
|
||||
return a:vector_add_inplace(b)
|
||||
return a:vector_add(b)
|
||||
end
|
||||
|
||||
function vec2.__sub(a, b)
|
||||
return a:vector_sub_inplace(b)
|
||||
return a:vector_sub(b)
|
||||
end
|
||||
|
||||
function vec2.__mul(a, b)
|
||||
if type(a) == "number" then
|
||||
return b:scalar_mul_inplace(a)
|
||||
return b:scalar_mul(a)
|
||||
elseif type(b) == "number" then
|
||||
return a:scalar_mul_inplace(b)
|
||||
return a:scalar_mul(b)
|
||||
else
|
||||
return a:vector_mul_inplace(b)
|
||||
return a:vector_mul(b)
|
||||
end
|
||||
end
|
||||
|
||||
function vec2.__div(a, b)
|
||||
if type(b) == "number" then
|
||||
return a:scalar_div_inplace(b)
|
||||
return a:scalar_div(b)
|
||||
else
|
||||
return a:vector_div_inplace(b)
|
||||
return a:vector_div(b)
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user