public void PostDeltaCalculation(Rectangle rect)
{
if (rect.Left <= mBoundaryX || rect.Right > mOffsetX
|| rect.Top <= mBoundaryY || rect.Bottom > mOffsetY)
{
// relevant to this node (overlaps)
// each non-leaf node should know which of its children transitions
// to the lower LOD level last, because this is the one which controls
// when the parent takes over
if (!IsLeaf)
{
float maxChildDelta = -1;
TerrainQuadTreeNode childWithMaxHeightDelta = null;
for (int i = 0; i < 4; i++)
{
TerrainQuadTreeNode child = mChildren[i];
child.PostDeltaCalculation(rect);
float childData = child.GetLodLevel((ushort)(child.LodCount - 1)).CalcMaxHeightDelta;
if (childData != 0)
{
}
if (childData > maxChildDelta)
{
childWithMaxHeightDelta = child;
maxChildDelta = childData;
}
}
// make sure that our highest delta value is greater than all children's
// otherwise we could have some crossover problems
// for a non-leaf, there is only one LOD level
LodLevel tmp = mLodLevels[0];
tmp.CalcMaxHeightDelta = System.Math.Max(tmp.CalcMaxHeightDelta, maxChildDelta * 1.05f);
mChildWithMaxHeightDelta = childWithMaxHeightDelta;
}
else
{
// make sure own LOD levels delta values ascend
for (int i = 0; i < mLodLevels.Count - 1; i++)
{
// the next LOD after this one should have a higher delta
// otherwise it won't come into affect further back like it should!
LodLevel tmp = mLodLevels[i];
LodLevel tmpPlus = mLodLevels[i + 1];
tmpPlus.CalcMaxHeightDelta = System.Math.Max(tmpPlus.CalcMaxHeightDelta, tmp.CalcMaxHeightDelta * 1.05f);
}
}
}
}
/// <summary>