Jump to content
  • Advertisement
Sign in to follow this  
MultiverseLabyrinth

Swept AABB -- Corners

This topic is 2134 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!