1
\$\begingroup\$

I am attempting to understand collision detection at the moment. I have seen many examples of a simple flat plane with boxes or cubes which move around on the plane and react when the touch each other (or stop at the plane when dropped).

What I am not finding though are more advanced examples where instead of just a flat plane, your map is made up of hills, buildings, walls, etc.

Since all of the examples I have found this far use simple primitive collision object types (boxes and spheres), I am curious what the best approach would be for creating a collision object for something like a game map (like dust2 in counter-strike).

After reading through the bullet documentation I found that you can create a collision object from a triangle mesh, which leads me to believe this might be the best approach. However if your map consists of complex geometry (say hundreds of thousands of verticies and faces), would this be too detailed to use as a collision mesh? Would it then be better to create a separate collision version of the map which is made of simple low poly shapes?

My gut is saying "go with the separate low poly version", but if there is no reason for the extra work, it would make more sense to just use the high poly mesh.

\$\endgroup\$
  • \$\begingroup\$ "...would this be too detailed to use as a collision mesh? Would it then be better to create a separate collision version of the map which is made of simple low poly shapes?" it's not exactly clear to me, what you are worried about specifically? Performance? Exactness? Algorithmic tractability? \$\endgroup\$ – Trilarion May 23 at 10:55
  • 1
    \$\begingroup\$ @Trilarion Performance specifically. My worry is that the algorithm to check if an object has collided with the map object would take too long to run efficiently within my loop making the game un-playable. \$\endgroup\$ – nullReference May 23 at 15:04
  • \$\begingroup\$ Do you maybe have a specific framework in mind that you want to use (like the mesh collider in Unity)? Also, without an example verifying the worry, it might be some kind of premature optimization. \$\endgroup\$ – Trilarion May 23 at 15:26
  • \$\begingroup\$ @Trilarion No framework in mind, as this would ultimately be implemented in a custom c++ / opengl application. I agree this might just be me worrying for no reason. I believe my plan of action is going to be to use the map mesh as the collision object and profile the performance. \$\endgroup\$ – nullReference May 23 at 16:29
0
\$\begingroup\$

Generating collision from the mesh itself is the usual approach for terrain. This is especially not a performance issue on counter strike-sized maps, as long as you keep the vert density at a somewhat sane value (0.5-10m).

If your level is already very geometric, or you need to have perfectly flat collision surfaces for some reason, look into replacing the collision with a bunch of collision boxes.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.