Skip to content

Commit 41bbccc

Browse files
committed
Fix bug triggering kinds twice during collision
1 parent 7be4967 commit 41bbccc

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/manager/physix.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,22 @@ local Manager = { }
119119
local l2 = s[i2]
120120
if l1 and l2 then
121121
local c1
122+
local intersected = { }
122123
for j = 1, #l1.items do
123124
c1 = l1.items[j]
125+
intersected[c1] = { }
124126
traverse(l2.grid, c1, function (cell)
125127
local c2, _
126128
for k = 1, #cell do
127129
c2 = cell[k]
128-
if Cube:isIntersecting(c1.x, c1.y, c1.z, c1.w, c1.h, c1.d, c2.x, c2.y, c2.z, c2.w, c2.h, c2.d) then
130+
if not intersected[c1][c2] and Cube:isIntersecting(c1.x, c1.y, c1.z, c1.w, c1.h, c1.d, c2.x, c2.y, c2.z, c2.w, c2.h, c2.d) then
131+
intersected[c1][c2] = true
129132
_ = c1.action and c1.action(c1.owner, c2.owner, c1, c2)
130133
_ = c2.action and c2.action(c2.owner, c1.owner, c2, c1)
131134
end
132135
end
133136
end)
137+
intersected[c1] = nil
134138
end
135139
end
136140
end

0 commit comments

Comments
 (0)