public override void NotifyCurrentCamera( Camera cam )
{
// Calculate squared view depth
Vector3 diff = cam.LodCamera.DerivedPosition;
float squaredDepth = diff.LengthSquared;
// Determine whether to still render
float renderingDist = mParent.RenderingDistance;
if ( renderingDist > 0 )
{
// Max distance to still render
float maxDist = renderingDist + mBoundingRadius;
if ( squaredDepth > Utility.Sqr( maxDist ) )
{
beyondFarDistance = true;
return;
}
}
beyondFarDistance = false;
// Distance from the edge of the bounding sphere
mCamDistanceSquared = squaredDepth - mBoundingRadius * mBoundingRadius;
// Clamp to 0
mCamDistanceSquared = Utility.Max( 0.0f, mCamDistanceSquared );
// Determine active lod
mCurrentLod = (ushort)( mLodSquaredDistances.Count - 1 );
Debug.Assert( mLodSquaredDistances.Count != 0 );
mCurrentLod = (ushort)( mLodSquaredDistances.Count - 1 );
for ( ushort i = 0; i < mLodSquaredDistances.Count; ++i )
{
if ( mLodSquaredDistances[ i ] > mCamDistanceSquared )
{
mCurrentLod = (ushort)( i - 1 );
break;
}
}
}