public void GetLocalBoundingBox(ref RigidTransform shapeTransform, ref AffineTransform spaceTransform, out BoundingBox boundingBox)
{
#if !WINDOWS
boundingBox = new BoundingBox();
#endif
//TODO: This method peforms quite a few sqrts because the collision margin can get scaled, and so cannot be applied as a final step.
//There should be a better way to do this.
//Additionally, this bounding box is not consistent in all cases with the post-add version. Adding the collision margin at the end can
//slightly overestimate the size of a margin expanded shape at the corners, which is fine (and actually important for the box-box special case).
//Move forward into convex's space, backwards into the new space's local space.
AffineTransform transform;
AffineTransform.Invert(ref spaceTransform, out transform);
AffineTransform.Multiply(ref shapeTransform, ref transform, out transform);
GetBoundingBox(ref transform.LinearTransform, out boundingBox);
boundingBox.Max.X += transform.Translation.X;
boundingBox.Max.Y += transform.Translation.Y;
boundingBox.Max.Z += transform.Translation.Z;
boundingBox.Min.X += transform.Translation.X;
boundingBox.Min.Y += transform.Translation.Y;
boundingBox.Min.Z += transform.Translation.Z;
}