public static bool RemoveChildFromCompound(Entity<CompoundCollidable> compound, Func<CompoundChild, bool> removalPredicate, IList<ShapeDistributionInformation> childContributions,
out ShapeDistributionInformation distributionInfo)
{
float weight;
float removedWeight;
Vector3 removedCenter;
if (RemoveChildFromCompound(compound.CollisionInformation, removalPredicate, childContributions, out distributionInfo, out weight, out removedWeight, out removedCenter))
{
//Reconfigure the entities using the data computed in the split.
//Only bother if there are any children left in the compound!
if (compound.CollisionInformation.Children.Count > 0)
{
float originalMass = compound.mass;
float newMass = (weight / (weight + removedWeight)) * originalMass;
Matrix3x3.Multiply(ref distributionInfo.VolumeDistribution, newMass * InertiaHelper.InertiaTensorScale, out distributionInfo.VolumeDistribution);
compound.Initialize(compound.CollisionInformation, newMass, distributionInfo.VolumeDistribution, distributionInfo.Volume);
RemoveReposition(compound, ref distributionInfo, weight, removedWeight, ref removedCenter);
}
return true;
}
else
return false;
}