How does SetDensity find volume, and how can I get it?

It uses the collider to at least estimate volume (using a mesh collider here) for calculating total mass, but I can’t find any way for the client (me) to access it. And it doesn’t use the bounding box, I’ve tested.

I’m only using regular polyhedrons, and subdivisions of those polyhedrons, so calculating volume myself won’t be overly complicated. Still, if volume is accessible, I’d love to have it. Depending on how Unity does it, I might also want to use more complex shapes.

I don’t know how Unity finds volume, but you can reverse it. That is, you can do something like:

function Start () {
	rigidbody.SetDensity(5.0);
	Debug.Log("mass: "+rigidbody.mass);
	Debug.Log("Volume: "+rigidbody.mass/5.0);

}  

In a bit of play I found the mass gets set back to the default of 1.0, any time the Transform.localScale is changed. An if you do a non-uniform scale of an object, the volume will reflect how Unity scales the collider. For example, box colliders get scaled non-uniformly, but sphere colliders apparently do not.

Note in searching around for an answer, I found this post which calculates the volume of mesh (I did not test it):

http://answers.unity3d.com/questions/52664/how-would-one-calculate-a-3d-mesh-volume-in-unity.html