Public Group

3D Bounding box collisions

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

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 on other sites

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 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.

• Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 21
• 22
• 11
• 25