void GetBoundingSphere(ref Vector3 terrainOffset, float patchScale, float heightScale, out BoundingSphere sphere)
{
var min = new Vector3
{
X = x * patchScale + terrainOffset.X,
Y = minHeight * heightScale + terrainOffset.Y,
Z = y * patchScale + terrainOffset.Z
};
var max = new Vector3
{
X = (x + size) * patchScale + terrainOffset.X,
Y = maxHeight * heightScale + terrainOffset.Y,
Z = (y + size) * patchScale + terrainOffset.Z
};
var center = max - min;
var radius = center.Length() * 0.5f;
sphere = new BoundingSphere(center, radius);
}