Ejemplo n.º 1
0
        /// <summary>
        /// Intersection test between plane and bounding sphere.
        /// </summary>
        /// <param name="bb"></param>
        /// <returns>
        /// return 1 if the bb is completely above plane,
        /// return 0 if the bb intersects the plane,
        /// return -1 if the bb is completely below the plane.
        /// </returns>
        public int Intersect(IBoundingBox bb)
        {
            var lowerBBCorner = bb.Corner(_lowerBBCorner);
            var distLower     = Distance(lowerBBCorner);

            // If lowest point above plane than all above.
            if (Distance(bb.Corner(_lowerBBCorner)) > 0.0f)
            {
                return(1);
            }

            var upperBBCorner = bb.Corner(_upperBBCorner);
            var distUpper     = Distance(upperBBCorner);

            // If highest point is below plane then all below.
            if (Distance(bb.Corner(_upperBBCorner)) < 0.0f)
            {
                return(-1);
            }

            // Otherwise, must be crossing a plane
            return(0);
        }