Advertisement Jump to content
Sign in to follow this  

Collision detection with a complex mesh

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


I'm currently struggling with the implementation for collision detection for the rooms in my game. The problem is that the rooms are a single mesh loaded from an .x file, and come in different shapes and sizes, so creating a single bounding box over the entire room isn't sufficient. Ideally I would like to create a bounding box on each wall in the room, but I'm not sure if that is possible. Is there a way to somehow read each wall into a separate mesh? Or is there a better way to implement the collision detection with a single room mesh? Thanks for any help.

Share this post

Link to post
Share on other sites
Are they simple rooms ? Can you do per triangle/quad collision over the full room? Otherwize you might have to create a tool to generate your collision surfaces given a room mesh, with rules about what to exclude or simplify. And the ability to manually adjust that collision mesh if your tool doesn't provide a good solution.

Rather than bounding box for each wall, I would choose a polygonal surface, or a planar surface if the walls are not complex / convex, that would be a faster computation wouldn't it. But you might prefer a slightly slower but more general function, such as bounding box, especially if all your walls are orthogonal. Im assuming your problem is trying to differentiate each wall in the mesh in order to fit the bounding box.

It may very much depend on what your geometry is like. And is this your own physics engine ?

Just some thoughts anyway. I have mostly worked on 2d physics, so I can't really offer much more than suggestions and discussion about how to tackle 3d physics.

Share this post

Link to post
Share on other sites
Oh no. No no no.
Don't even think about taking your graphics assets and dumping them to collision routines. They'll often fail in at least one of two cases

  1. Performance wise, they contain way more triangles than enough for CD. This results in worse performance and often decreased simulation quality.
    But hey, I bet your game is simple enough and perhaps you're running this on i7 so you could do that anyway.
  2. Gameplay wise, not all meshes are solid.
    If you're tempted to add the appropriate switches, you'll end up messing up your mesh representation with physics data. It will only end up in tears.

As a reference, Unreal Technology enriches each mesh with a proper collision hull. Worlds come with a graphics representation and a physics representation and there are two types of "physics", physx and internal. As far as I understand, neither works on the graphics mesh in general (albeit some operations are performed on the graphic meshes depending on settings).

So, decoupling graphics from physics appears the way to go.
I can tell my code improved a lot since I did so and I strongly suggest to do the same.

As a side note, don't even try doing CD for an arbitrary mesh. Use a library such as Gimpact if you want to be "low level" or even better, use Bullet, which packs it in for you with plenty of other features.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!