/// <summary>
/// Computes a convex shape description for a TransformableShape and applies it.
/// </summary>
public void UpdateConvexShapeInfo()
{
//Compute the volume distribution.
var samples = CommonResources.GetVectorList();
if (samples.Capacity < InertiaHelper.SampleDirections.Length)
{
samples.Capacity = InertiaHelper.SampleDirections.Length;
}
samples.Count = InertiaHelper.SampleDirections.Length;
for (int i = 0; i < InertiaHelper.SampleDirections.Length; ++i)
{
shape.GetLocalExtremePointWithoutMargin(ref InertiaHelper.SampleDirections[i], out samples.Elements[i]);
}
var triangles = CommonResources.GetIntList();
ConvexHullHelper.GetConvexHull(samples, triangles);
Fix64 volume;
InertiaHelper.ComputeShapeDistribution(samples, triangles, out volume, out volumeDistribution);
Volume = volume;
//Estimate the minimum radius based on the surface mesh.
MinimumRadius = InertiaHelper.ComputeMinimumRadius(samples, triangles, ref Toolbox.ZeroVector) + collisionMargin;
MaximumRadius = ComputeMaximumRadius();
CommonResources.GiveBack(samples);
CommonResources.GiveBack(triangles);
}