- Home /
How can I detect Actors which will cause the "Compute mesh inertia tensor failed!" error?
Our project has a few of these: Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
I've read various threads, like this one: http://forum.unity3d.com/threads/8342-Error-unknown-from-quot-Actor-updateMassFromShapes-quot
Or this: http://answers.unity3d.com/questions/7841/what-does-the-compute-mesh-inertia-tensor-failed-e.html
...which discuss how to fix the problem. However, I can't even locate the objects generating the error (we have thousands of objects in our scene).
I'm trying to write an Editor script which will detect objects with the properties that trigger this, but no matter what I try I still get the error.
I've tried: MeshColliders with a mesh where extents are 0 in one dimension, MeshColliders lacking a mesh, non-convex MeshColliders with a RigidBody attached, MeshColliders with RigidBodies that have an inertia tensor of magnitude 0, and RigidBodies that have inertia tensors of 1.0 in all dimensions (it seemed like MeshColliders with missing meshes generated (1, 1, 1) inertia tensors, so I thought that might be the default).
Anyone have any more suggestions for me?
Thanks!
Answer by ivarboms · Mar 18, 2013 at 08:50 AM
I believe this is typically caused by rigid bodies with mesh colliders whose extents in any axis is 0, or some other exceptional geometry which makes PhysX unable to calculate the inertia tensor automatically. This error is reproducible by creating a standard Unity plane, and then adding a rigid body to it.
The most likely case is that you have some rigid bodies with plane mesh colliders.
Yeah, that's what I assumed, too, but detecting $$anonymous$$eshCollider.shared$$anonymous$$esh.bounds.extents of zero didn't find the offending objects. Is there some other property I should be checking?
Checking the extents might not work in cases where for instance you have a plane mesh which is not axis aligned, meaning the bounds will not be zero. One solution could be calculating the smallest bounding box of all the meshes used for colliders, and then looking at the extents of those bounding boxes. I'm sure there's a better way to do this too, but that's the first way I could think of.
Another possibility could be simply finding $$anonymous$$eshCollider.shared$$anonymous$$eshes whose name contains "plane", might get you some results if you're lucky.