Jump to content
  • Advertisement
Sign in to follow this  
coffeecup

get colliding face of 2 AABB's?

This topic is 2123 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

So far I have 2 AABB's, one stationary and one moving, checking against min(x,y,z) and max(x,y,z) of the 2 AABB's I can tell if they intersect.

 

Now I would like to implement a "slide against the wall" effect, therefore I need to get the normal of the colliding face, but I have troubles understanding how I can compute which face is colliding.

 

I googled a lot and found something about SAT (  http://www.codezealot.org/archives/55 ) but I am still confused, is this the only technique to get the colliding face or are there other options available?

 

 

I would appreciate some hints or pseudo code to get me started.

 

Share this post


Link to post
Share on other sites
Advertisement
SAT works by finding all the common axises (sp?) between the two colliders and see how much they overlap. If one of them doesn't overlap, there's no collision. Otherwise the collision normal can be devised from the overlaps.

AABB's, by definition, have the common axises global x, y and z. With the min/max tests you find out if all of them overlap or not. So what's left to do, is figure out, how much they overlap, and them simply pick the largest overlap, since the axises are also, by definition, the face normals.

I hope that helps!

And maybe someone can let me know what the correct plural of axis is... ;)

Share this post


Link to post
Share on other sites

thanks, indeed that helped, i got a little confused reading so much stuff about SAT.

 

now i calculate the distance between the 2 boxes using the min and max values for each axis and take the largest distance which gives me the correct normal.

 

the plural of axis is axes.

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!