Primitive Colliders vs Mesh Colliders

I am trying to understand when to use mesh colliders:

1 - How many primitive box colliders will have the same performance impact as a box mesh collider.

2 - Lets say I have a model of 3500 tri’s. I can cover it with 10 primitive box colliders, varying of sizes. From what I understand that is 60 face checks. Primitive colliders do not do tri checks. if I create a custom mesh collider that cover the model properly with 60 tri’s. What is the performance difference? Keep in mid that each primitive collider had to have its own empty gameobject plus the parent storing them. Optimization is very import, due to me trying to understand whats going on in the background.

3 - How much primitive colliders is to much for a model, were a custom mesh collider would be better?

4 - Understand what I am asking?

James

I agree that you should check the profiler, but it may help you to actually look into how the hit-tests are performed. Mesh colliders are probably using a variant of GJK algorithm, which performs well enough, but is iterative (I can’t find its runtime online, but it’s probably around O(log n). I expect unity’s primitive types, however, to all be O(1) operations. And while this is a pure guess, I’d estimate fastest to slowest would be Sphere > Box > Capsule.

Now if all this is true, you should be able to estimate the ratio of primitives to mesh polys that would give you better performance. In the case you listed, I would predict 10 box colliders to out-perform one mesh of 3500 tris. The performance overhead of additional gameobjects should be negligible, and I’ve personally had games hum above 60fps in procedurally-generated maps made of thousands of box colliders.

So I hope this helps inform your decision a bit, but @Eric5h5 gave you the practical answer in his comment - profile it!

Some other things to consider, which can make compound (primitive) colliders better:

o Sphere and Capsule colliders are more perfect than sphere-made-of-tris mesh colliders.

o Will the result be concave? There are no issues(?) with building an effectively concave collider out of primitives. But concave mesh colliders don’t interact properly with some things (I think only other concave Mesh colliders.)

o Some code-based tests may run only on simple colliders (sweeptest, the new instant overlap tests.)

o Can do some fun tricks with tagging the parts of complex colliders (for use in collision code,) or giving them different physics materials.