Reputation: 9218
In Unity is there a way during runtime, when dealing with unknown user-generated shapes for which we now want to create a meshCollider, to calculate whether the mesh should set to be Convex or not, i.e. whether the meshFilter has inward curves? (It's easy enough to set this property manually by looking at it, but here I'm dealing with unknown-beforehand shapes.) Thanks!
Upvotes: 0
Views: 909
Reputation: 1945
For each triangle in the mesh, you need to calculate its face normal. Then for each face normal, check the sign of the dot product with each vertex to see if its behind the triangle. If all vertices are behind all triangles, it is convex.
Personally, I would just mark everything concave and move on.
Upvotes: 1