# AABB collision detection with world

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

## Recommended Posts

I'm trying to program a very simple fps and I'm having some trouble with collision detection with the world. I haven't implemented any space partitioning yet so I'm just working with a list of triangles. I was able to get point-based collision detection working by detecting whether the player's position point passed a polygon's plane and determining if the point is in the poly. Now I've put the player in an AABB. Do I need to do the same tests with all 8 points of the bounding box or is there a more efficient way?

##### Share on other sites
So I've got collision detection working as stated above with the player surrounded by an AABB and the system being able to detect a collision with the world by testing all 8 points of the box. It's successful in the sense that I've prevented the player from walking right up against walls but when I rotate the camera it still cuts through the wall. I've compensated for that by making the AABB bigger but in order to prevent it from happening the AABB had to be far too big to be manageable (eg. the player couldn't fit through doors). Surely there must be a better way?

##### Share on other sites
Quote:
 Original post by santonelSo I've got collision detection working as stated above with the player surrounded by an AABB and the system being able to detect a collision with the world by testing all 8 points of the box. It's successful in the sense that I've prevented the player from walking right up against walls but when I rotate the camera it still cuts through the wall. I've compensated for that by making the AABB bigger but in order to prevent it from happening the AABB had to be far too big to be manageable (eg. the player couldn't fit through doors). Surely there must be a better way?

1. For simplicity, the AABB should probably be sized such that it can fully contain the object in all orientations. (I'm a bit surprised that you're finding an AABB large enough to contain a humanoid to be unmanageable...)

2. The '8 point' method is not an effective intersection test (it will miss many cases, such as those where an edge or face intersects an object before any of the corners do). Alternatives include the SAT, or intersection with a BSP tree representing your world geometry.

##### Share on other sites
Original post by jyk
Quote:
 A couple of quick comments:1. For simplicity, the AABB should probably be sized such that it can fully contain the object in all orientations. (I'm a bit surprised that you're finding an AABB large enough to contain a humanoid to be unmanageable...)2. The '8 point' method is not an effective intersection test (it will miss many cases, such as those where an edge or face intersects an object before any of the corners do). Alternatives include the SAT, or intersection with a BSP tree representing your world geometry.

I should mention that (although I'm not proud to say it) I'm sort of a noob at this stuff in that I can't seem to wrap my head around the mathematics of 3d game programming very well.

1. Well I'm not using a model for the player. Just a camera in an AABB so I've just been swapping in values
that seem to enclose it in a rectangular shape. It works enough for detecting collisions with the world and keeping the player x units from the wall, what's unmanageable is the size I have to make it to prevent the camera from cutting into the wall when I rotate it when the player is up against a wall. Perhaps I'll have to size the box big enough to prevent it and scale the level large enough to compensate?

2. Indeed it isn't very effective. The goal right now is simplicity. If I can get the player to not walk through walls I'm happy (for now). Just getting it work at all is the primary objective. The objective now is to be able to load a small map as a polygon soup and be able to collide with the walls. Then I can add space partitioning , better collision detection, etc....

As for SAT and BSP, I wanted to ask questions about them too. I've done some reading up on the SAT and I've roughly understood it to work like this:

-Project all the points of the 2 polys on a line
-If the points a point can be found that separates the points from polygon a from polygon b then they don't intersect.

I have no idea how to do it mathematically. I've tried to read Moller's paper on it but I don't understand it all. I really need something explained to me in plain english. Other than that I haven't found any other good information on the SAT.

I have only a partial understanding of BSP (I was planning on using an Octree for my fps but im not against using BSP). I read in 3D Game Engine Programming that there exists a variety of BSP tree than you can use to do collision detection without any intersection tests (or something like that). I don't really get how it works. If someone could explain it to me it would be great but I'd just like to solve the camera problem right now.

• 36
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631359
• Total Posts
2999544
×