Skip to main content
GameDev.net gamedev.net
🔒 Locked

AABB collision help!

Started by GamerYZ May 18, 2006 at 1:15 AM 2 replies 1k views
Original Post
GamerYZ
GamerYZ
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.
head_hunter
head_hunter
If your tree is tight, then you could store node adjacency information in each node and use it to jump from node to node as you follow the line through space.
dawidjoubert
dawidjoubert
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 collisionif ((O.x > B.X) && (P.x > B.x)) return false; // No collisionif ((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.
----------------------------http://djoubert.co.uk
GamerYZ
GamerYZ
thanks for the reply, problem fixed :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.