I’m working on a cave system that generates a lot like a voxel engine. It is however not a voxel engine and so does not use the mesh for collision. I certainly could do this, but I wonder, would boxes be faster?
For example, in some situations five of the six faces of a cube are visible. I assume in this case the box collider would be faster than a five faced mesh collider even though the box collider has more faces.
But is that true? Is a mesh collider inherently calculated differently making it slower than a box collider no matter what? For example, is a 10x10x10 cube mesh collider (12 triangles) slower than a 10x10x10 box collider? What if the mesh moves a vertex losing its perfection?
Could the mesh collider calculate faster than the box collider in certain situations, like when only five faces are present? What if it were only one angled face? Is this still slower than a box collider? Is this inherently slower than a plane collider?
Currently I’m considering instantiating box colliders all along the walls even in cases where only one face is visible, but MAIN QUESTION:
maybe I should switch to meshes to keep the face count down?
Or does face count not matter as we’re not talking about rendering/batches, simply ray/character collision detection and using boxes is better than meshes. Does having extra collision faces in the scene not impact performance if they are not being used, disregarding memory?
Convex mesh colliders perform close or the same to a box collider where triangle count and size is theoretically the same, but sphere/capsule is faster.
Mesh colliders that are not convex are always slower.
You could test this or read the docs which mentions it. In any case, just using a non convex mesh collider will pretty much ALWAYS be slower and won’t even work if it’s moving/rotating (you cannot have dynamic non-convex mesh colliders).
Sticking with a lot of box colliders is generally better. Bench it.
Kind of orthogonal to your question, but have you thought about dynamic mesh combining? I created a dynamic underground tunneling/build system and that’s what I did to solve this.
well ya I’m already generating and combining the mesh for rendering on the fly so it would be easy as pie to use the same deal for colliders. that’s how any voxel engine worth beans works. I just wasn’t sure if a five square mesh collider would be slower than a six sided box collider for some strange reason or not. clearly it is more about triangle count than simple mesh or box though.