I am procedurally generating a tubular structure. The radius/shape varies over the length of the tubular structure. For my purposes I need accurate physics on that shape. As the tube is constructed by connecting ring A of vertices with ring B of vertices with ring C of vertices etc, etc, I want to know what would be better performance-wise. Should I make the entire tubular structure one mesh for colliders or should I break each ring-to-ring segment into a separate child collider mesh of the parent visible geometry?
Essentially, is it better to have one large multi-segment tubular mesh collider or should I break each segment of the tubular structure into a different mesh collider.
I know that mesh colliders are more expensive. If there were a good way to do this with just spheres I would do that, but I really need as close to precise result as I can get for this application.
I’m sure you’ve solved this, and I’m not sure how this would scale to your project, but if performance is a concern, this is what I would do.
Create an invisible mesh that copies just the vertices closest to whatever object will be colliding with the tube. I can’t imagine this would be too hard, provided that the distance between rings is known and each ring has the same number of vertices. This will give you accurate collisions, but only worry about relevant vertices
Personally I think that you must split in objects of avarage size. I don’t know how unity3d engine works. But exists many types of otimizations used by physic engines to exclude a object from collision test that didn’t apply for large or concave objects.
For example, you can have a AABB (Bounding volume - Wikipedia) for each game object and put into a octree (Octree - Wikipedia), only objects in the same octree node that collide your AABB you must check for mesh colision. For a large mesh, the AABB will always have contact and you must always check for mesh collision.
But in the end, it is better make what is easy for you and test for perfomance.