Don't mess with vector types.

This commit is contained in:
TSnake41 2020-05-09 23:10:59 +02:00
parent 10fe371292
commit db4c56cbd2
1 changed files with 4 additions and 4 deletions

View File

@ -74,13 +74,13 @@ ffi.metatype("Vector3", {
end,
__sub = function (a, b)
if ffi.istype("Vector3", b) then
return new("Vector2", a.x - b.x, a.y - b.y, a.z - b.z)
return new("Vector3", a.x - b.x, a.y - b.y, a.z - b.z)
else
error "Invalid operation."
end
end,
__unm = function (a)
return new("Vector2", -a.x, -a.y, -a.z)
return new("Vector3", -a.x, -a.y, -a.z)
end,
__len = function (a)
return math.sqrt(a.x * a.x + a.y * a.y + a.z * a.z)
@ -91,10 +91,10 @@ ffi.metatype("Vector3", {
a, b = b, a
end
if ffi.istype("Vector2", b) then -- dot product
if ffi.istype("Vector3", b) then -- dot product
return a.x * b.x + a.y * b.y + a.z * b.z
elseif type(b) == "number" then
return new("Vector2", a.x * b, a.y * b, a.z * b)
return new("Vector3", a.x * b, a.y * b, a.z * b)
else
error "Invalid operation."
end