0
\$\begingroup\$

I need to get the number of vertices a mesh collider's mesh has. As pointed out in the comments this may not even be a mesh anymore, but is there a way to count the vertices of whatever data structure a MeshCollider uses to store it's 'mesh'? I'm currently using

MeshCollider.sharedMesh.vertexCount; 

But seems to get the mesh that the collider initially uses and has a reference to, not the what actually used by the physics simulation. As cooking -> cook for faster simulation seems to drastically alter this mesh.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ It's not specified in the docs that the result of cooking even is a mesh. It could be a different data structure. So you might want to reframe your question as "How to count the vertices in a mesh collider". Possible reasons the mesh collider might use fewer vertices are if it's combining co-located vertices, or if it's convex and discarding concave vertices - both of which you can detect by analyzing the original source mesh. Just be sure to specify in your question whether the convex option applies to your case. \$\endgroup\$
    – DMGregory
    Aug 18, 2020 at 13:59
  • \$\begingroup\$ @DMGregory The documentation says "Mesh cooking changes a normal Mesh into a Mesh that you can use in the physics engine." docs.unity3d.com/Manual/class-MeshCollider.html \$\endgroup\$
    – Kevin
    Aug 20, 2020 at 2:07

0

You must log in to answer this question.

Browse other questions tagged .