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:
Max Cahill 2024-01-19 10:25:04 +11:00
parent 3d03d3238a
commit ef4ef69b0f

View File

@ -455,28 +455,28 @@ end
-- meta functions for mathmatical operations -- meta functions for mathmatical operations
function vec2.__add(a, b) function vec2.__add(a, b)
return a:vector_add_inplace(b) return a:vector_add(b)
end end
function vec2.__sub(a, b) function vec2.__sub(a, b)
return a:vector_sub_inplace(b) return a:vector_sub(b)
end end
function vec2.__mul(a, b) function vec2.__mul(a, b)
if type(a) == "number" then if type(a) == "number" then
return b:scalar_mul_inplace(a) return b:scalar_mul(a)
elseif type(b) == "number" then elseif type(b) == "number" then
return a:scalar_mul_inplace(b) return a:scalar_mul(b)
else else
return a:vector_mul_inplace(b) return a:vector_mul(b)
end end
end end
function vec2.__div(a, b) function vec2.__div(a, b)
if type(b) == "number" then if type(b) == "number" then
return a:scalar_div_inplace(b) return a:scalar_div(b)
else else
return a:vector_div_inplace(b) return a:vector_div(b)
end end
end end