Jump to content

View more

Image of the Day

WIP title screen for #DeathOfAPartisan #screenshotsaturday #gamedev https://t.co/qJNhfZCvd4
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.

Sign up now

Collision detection with a complex mesh

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 SisuMeeks   Members   


Posted 28 November 2012 - 03:56 PM


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.

#2 Gavin Williams   Members   


Posted 29 November 2012 - 12:33 AM

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.

#3 MaxDZ8   Members   


Posted 29 November 2012 - 04:45 AM

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

Previously "Krohm"

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.