0
루아에 표시된 on this page과 같이 Gomez의 Swept-AABB 대 AABB 충돌 감지 알고리즘을 포트에 연결하려고하는데 작동하지 않습니다. 다른 부정확성 중에서도 출력 시간이 0에 가까운 "충돌"을 거의 모든 곳에서 감지합니다. 내가 뭔가 잘못하고 있는거야?Swept-AABB 대 AABB 충돌 테스트가 작동하지 않습니다.
local axis = {"x","y","z"}
-- box1 is the moving box, disp is the box's displacement, box2 is stationary
function Collision.swept_aabb_vs_aabb(box1, disp, box2)
local a = box2
local b = box1
local amin = a:minCorner()
local amax = a:maxCorner()
local bmin = b:minCorner()
local bmax = b:maxCorner()
local u0d, u1d = vector(0,0,0), vector(1,1,1)
for i=1,3 do
local ax = axis[i]
if amax[ax] < bmin[ax] and disp[ax] < 0 then
u0d[ax] = (amax[ax] - bmin[ax])/disp[ax]
elseif bmax[ax] < amin[ax] and disp[ax] > 0 then
u0d[ax] = (amin[ax] - bmax[ax])/disp[ax]
end
if bmax[ax] > amin[ax] and disp[ax] < 0 then
u1d[ax] = (amin[ax] - bmax[ax])/disp[ax]
elseif amax[ax] > bmin[ax] and disp[ax] > 0 then
u1d[ax] = (amax[ax] - bmin[ax])/disp[ax]
end
end
local u0 = max(u0d.x,u0d.y,u0d.z)
local u1 = min(u1d.x,u1d.y,u1d.z)
if u0 <= u1 then return u0 else return nil end
end
편집 : 그것은 보인다위한 u0d에 값을 할당 조건을 트리거하는 경우, 좀 더 테스트를 할 것의 아무도 축 3.