Jump to content
• Advertisement

Public Group

# 3D Bounding box collisions

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

Ive been working with making a simple 3d game in C++ using DirectX9. I have a decent understanding and have got to a point where i am rendering a scene with some .X Meshes and the camera can fly around and stuff. I have been trying to perform some simple collision detections between bounding boxes, but dont know exactly how do do it. I can detect if two bounding boxes are intersecting given the size and coordinates of said boxes. But i was wondering how to do that with multiple objects in a scene. I was thinking of ways to do that, but all i could come up with would be to have a list of all the objects in a scene and just loop through that and test for collisions with each one. But surely that has to be an inefficient way of detecting collisions, especially if there are a lot of objects. i looked around but couldnt find much so any help would be appreciated. as i said i am working with c++ and dx9, and would try not to use anyone else's physics engine or other things like that.

#### Share this post

##### Share on other sites
Advertisement

Ive been working with making a simple 3d game in C++ using DirectX9. I have a decent understanding and have got to a point where i am rendering a scene with some .X Meshes and the camera can fly around and stuff. I have been trying to perform some simple collision detections between bounding boxes, but dont know exactly how do do it. I can detect if two bounding boxes are intersecting given the size and coordinates of said boxes. But i was wondering how to do that with multiple objects in a scene. I was thinking of ways to do that, but all i could come up with would be to have a list of all the objects in a scene and just loop through that and test for collisions with each one. But surely that has to be an inefficient way of detecting collisions, especially if there are a lot of objects. i looked around but couldnt find much so any help would be appreciated. as i said i am working with c++ and dx9, and would try not to use anyone else's physics engine or other things like that.

That is why you need to have some sort of Spatial management system such as an Octree or Quadtree. That way you only the test the Objects that are in the same tree level as the viewer.

#### Share this post

##### Share on other sites
Checking collision of each object on every other is inefficient but don't worry about optimizing at this stage. If you see a slowdown and identify the collision detection as the problem, then its a good time to find a way to speed it up. To answer the question on what you could do to speed things up I would recommend using a sweep and prune method or a spacial hash.

A spacial hash is fairly easy to make, basically it involves splitting up the scene into a grid then assigned each object to it's containing cell. Then when you want to check for collision you only need to check against objects in the cells it overlaps.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5
• Advertisement

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633735
• Total Posts
3013597
×

## 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!