Skip to content

Commit 4abb155

Browse files
committed
P2.postBroadphaserHandler updated to avoid skipping final 2 pairs.
1 parent bc1a24e commit 4abb155

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/physics/p2/World.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,16 +355,16 @@ Phaser.Physics.P2.prototype = {
355355
*/
356356
postBroadphaseHandler: function (event) {
357357

358-
var i = event.pairs.length;
358+
if (!this.postBroadphaseCallback || event.pairs.length === 0)
359+
{
360+
return;
361+
}
359362

360-
if (this.postBroadphaseCallback && i > 0)
363+
for (var i = event.pairs.length - 2; i >= 0; i -= 2)
361364
{
362-
while (i -= 2)
365+
if (event.pairs[i].parent && event.pairs[i+1].parent && !this.postBroadphaseCallback.call(this.callbackContext, event.pairs[i].parent, event.pairs[i+1].parent))
363366
{
364-
if (event.pairs[i].parent && event.pairs[i+1].parent && !this.postBroadphaseCallback.call(this.callbackContext, event.pairs[i].parent, event.pairs[i+1].parent))
365-
{
366-
event.pairs.splice(i, 2);
367-
}
367+
event.pairs.splice(i, 2);
368368
}
369369
}
370370

0 commit comments

Comments
 (0)