Swept AABB -- Corners

Started by
-1 comments, last by MultiverseLabyrinth 10 years, 7 months ago

Hello.

I've been working on some collision following the Swept AABB Collision Detection and Response article. Everything works fine except the corners. For whatever reason the corners can be hit like so:
collision.gif

I created a dirty fix for this by checking a large amount of xInvEntry, xInvEntry, yInvEntry, and yInvExit situations for each corner in each direction.


(xInvEntry == 0 && xInvExit == b1.width + b2.width && yInvEntry == b1.height + b2.height && yInvExit == 0)||
(xInvEntry == b1.width + b2.width && xInvExit == 0 && yInvEntry == 0 && yInvExit == b1.height + b2.height)||
(xInvEntry == 0 && xInvExit == -(b1.width + b2.width) && yInvEntry == b1.height + b2.height && yInvExit == 0)||
(xInvEntry == b1.width + b2.width && xInvExit == 0 && yInvEntry == 0 && yInvExit == -(b1.height + b2.height))||
(xInvEntry == 0 && xInvExit == -(b1.width + b2.width) && yInvEntry == 0 && yInvExit == -(b1.height + b2.height))||
(xInvEntry == 0 && xInvExit == (b1.width + b2.width) && yInvEntry == 0 && yInvExit == -(b1.height + b2.height))||
(xInvEntry == 0 && xInvExit == -(b1.width + b2.width) && yInvEntry == 0 && yInvExit == (b1.height + b2.height))

Now this doesn't completely solve the problem when moving through tile wide corridors, and also allows boxes to move through corners and into the box. Needless to say it doesn't suffice.

I was wondering what is the best way to fix this problem to allow smooth, uninterrupted movement across boxes, and what exactly is causing the problem to occur.

Thanks in advance for all help.

This topic is closed to new replies.

Advertisement