protected virtual void _updateWorldSpaceCorners()
{
Matrix4 eyeToWorld = _viewMatrix.InverseAffine();
// Note: Even though we could be dealing with general a projection matrix here,
// it is incompatible with the infinite far plane, thus, we need to work
// with projection parameters.
// Calc near plane corners
Real nearLeft, nearRight, nearBottom, nearTop;
CalculateProjectionParameters( out nearLeft, out nearRight, out nearBottom, out nearTop );
// Treat infinite fardist as some arbitrary far value
Real farDist = ( _farDistance == 0 ) ? 100000 : _farDistance;
// Calc far palne corners
Real ratio = _projectionType == Projection.Perspective ? _farDistance / _nearDistance : 1;
Real farLeft = nearLeft * ratio;
Real farRight = nearRight * ratio;
Real farBottom = nearBottom * ratio;
Real farTop = nearTop * ratio;
// near
_worldSpaceCorners[ 0 ] = eyeToWorld.TransformAffine( new Vector3( nearRight, nearTop, -_nearDistance ) );
_worldSpaceCorners[ 1 ] = eyeToWorld.TransformAffine( new Vector3( nearLeft, nearTop, -_nearDistance ) );
_worldSpaceCorners[ 2 ] = eyeToWorld.TransformAffine( new Vector3( nearLeft, nearBottom, -_nearDistance ) );
_worldSpaceCorners[ 3 ] = eyeToWorld.TransformAffine( new Vector3( nearRight, nearBottom, -_nearDistance ) );
// far
_worldSpaceCorners[ 4 ] = eyeToWorld.TransformAffine( new Vector3( farRight, farTop, -_farDistance ) );
_worldSpaceCorners[ 5 ] = eyeToWorld.TransformAffine( new Vector3( farLeft, farTop, -_farDistance ) );
_worldSpaceCorners[ 6 ] = eyeToWorld.TransformAffine( new Vector3( farLeft, farBottom, -_farDistance ) );
_worldSpaceCorners[ 7 ] = eyeToWorld.TransformAffine( new Vector3( farRight, farBottom, -_farDistance ) );
_recalculateWorldSpaceCorners = false;
}