Sign in to follow this  

AABB collision help!

Recommended Posts

I'm building an AABB tree for my 3D engine, and I need some pointers on optimizing it. First of all, my program is blowing up and getting "no memory" error if I attempt to put a reasonable amount(10 - 20 or so) of triangles into a single box, while the total triangle is around 4000ish. Secondly, how should I traverse through the tree and check for line-box collision? Currently my collision check actully runs alot shower then traversing the whole tree. Someone please give me some pointers, thanks.

Share this post

Link to post
Share on other sites
Post your ray->aabb testing algorithm.

A Simple rule of thumb is that for a ray and an aabb to colide it must collide on every axis.

if this is your box with sides ABCD

| C |
|A B|
| D |

And we have ray OP then you can perform the following quick exit tests

if ((O.x < A.X) && (P.x < A.x)) return false; // No collision
if ((O.x > B.X) && (P.x > B.x)) return false; // No collision
if ((O.y > D.y) && (P.y > D.y)) return false; // No collision

You get the idea, this is the MAIN advantage of having an AABB.. You have many early out tests.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this