Move box_box_collision to vector & fix it

This commit is contained in:
Lars Mueller 2020-12-21 19:48:37 +01:00
parent 27b2de0367
commit 7fde587dab
2 changed files with 9 additions and 9 deletions

@ -101,15 +101,6 @@ function check_player_privs(playername, privtable)
return missing_privs, to_lose_privs return missing_privs, to_lose_privs
end end
function box_box_collision(a, b)
for i=1, 3 do
if a[i] < (b[i] + b[i+3]) or b[i] < (a[i] + a[i+3]) then
return false
end
end
return true
end
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
for k, v in pairs(delta_times) do for k, v in pairs(delta_times) do
local v=dtime+v local v=dtime+v

@ -76,4 +76,13 @@ end
function clamp(v, min, max) function clamp(v, min, max)
return apply(apply(v, math.max, min), math.min, max) return apply(apply(v, math.max, min), math.min, max)
end
function box_box_collision(diff, box, other_box)
for index, diff in pairs(diff) do
if box[index] + diff > other_box[index + 3] or other_box[index] > box[index + 3] + diff then
return false
end
end
return true
end end