PagingLandScapeOctreeCamera::Visibility PagingLandScapeOctreeCamera::getVisibility( const AxisAlignedBox &bound ) const 
    {
        // Null boxes always invisible
        if ( bound.isNull() )
            return NONE;

        // Make any pending updates to the calculated frustum
        Camera::updateView();

        // Get corners of the box
        const Vector3 * const pCorners = bound.getAllCorners();

        // For each plane, see if all points are on the negative side
        // If so, object is not visible.
        // If one or more are, it's partial.
        // If all aren't, full

        static unsigned int corners[ 8 ] = {0, 4, 3, 5, 2, 6, 1, 7};

        static unsigned int planes[ 6 ] = {FRUSTUM_PLANE_TOP, FRUSTUM_PLANE_BOTTOM,
                        FRUSTUM_PLANE_LEFT, FRUSTUM_PLANE_RIGHT,
                        FRUSTUM_PLANE_FAR, FRUSTUM_PLANE_NEAR };

        bool all_inside = true;

        const bool infinite_far_clip = (mFarDist == 0);
        for ( int plane = 0; plane < 6; ++plane )
        {

            const unsigned int currPlane = planes[ plane ];

            // Skip far plane if infinite view frustum
            if (infinite_far_clip && currPlane == FRUSTUM_PLANE_FAR)
                continue;

            bool all_outside = true;
            const Plane &frustumPlane = mFrustumPlanes[ currPlane ];
            for ( unsigned int corner = 0; corner < 8; ++corner )
            {
                const Real distance = frustumPlane.getDistance( pCorners[ corners[ corner ] ] );
               
                all_outside = all_outside && ( distance < 0 );
                all_inside = all_inside && ( distance >= 0 );

                if ( !all_outside && !all_inside )
                    break;
            }

            if ( all_outside )
                return NONE;
        }

        if ( all_inside )
            return FULL;
        else
            return PARTIAL;

    }
static Sphere aabbToSphere(const AxisAlignedBox& aabb)
{
	if (!aabb.isNull())
	{
		// Compute sphere
		float radius = -1.0f;
		const Vector3* corners = aabb.getAllCorners();
		for(unsigned int i = 0; i < 6; ++i)
		{
			float distance = corners[i].distance(aabb.getCenter());
			if (distance>radius)
			{
				radius = distance;
			}
		}
		return Sphere(aabb.getCenter(), radius);
	}
    else
	    return Sphere(Vector3::ZERO, -1.0f);
}