Retrieve collision mesh from collider?

Well, it’s my job, but you’re also free to browse UnityPhysics code and see what’s under the hood. You can look inside <your_project>\Library\PackageCache\com.unity.physics@ folder or see this thread on how to make the package local and then you can regenerate solution that will include UnityPhysics source next to your code. Changing physics code is discouraged because it’s hard to maintain when you go to a newer version, but can sometimes be temporarily useful.

Here’s how you can get the mesh primitive vertices in your ILeafColliderCollector implementation:

public void AddLeaf(ColliderKey key, ref ChildCollider leaf)
{
var verts = ((PolygonCollider*)leaf.Collider)->Vertices;
...
}

Hoping this helps, please let me know if you need anything else.

1 Like