/// <summary>
        /// Gets a value indicating whether this <see cref="BoundingSphere"/> contains the specified frustum.
        /// </summary>
        /// <param name="frustum">A <see cref="BoundingFrustum"/> which represents the frustum to evaluate.</param>
        /// <returns>A <see cref="ContainmentType"/> value representing the relationship between this sphere and the evaluated frustum.</returns>
        public ContainmentType Contains(BoundingFrustum frustum)
        {
            Contract.Require(frustum, nameof(frustum));

            if (!frustum.Intersects(this))
            {
                return(ContainmentType.Disjoint);
            }

            var radiusSquared = Radius * Radius;

            foreach (var corner in frustum.CornersInternal)
            {
                Vector3 cornerRelativeToCenter;
                cornerRelativeToCenter.X = corner.X - Center.X;
                cornerRelativeToCenter.Y = corner.Y - Center.Y;
                cornerRelativeToCenter.Z = corner.Z - Center.Z;

                if (cornerRelativeToCenter.LengthSquared() > radiusSquared)
                {
                    return(ContainmentType.Intersects);
                }
            }

            return(ContainmentType.Contains);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a value indicating whether this <see cref="BoundingBox"/> contains the specified bounding frustum.
        /// </summary>
        /// <param name="frustum">A <see cref="BoundingFrustum"/> which represents the frustum to evaluate.</param>
        /// <param name="result">A <see cref="ContainmentType"/> value representing the relationship between this box and the evaluated frustum.</param>
        public void Contains(BoundingFrustum frustum, out ContainmentType result)
        {
            Contract.Require(frustum, nameof(frustum));

            if (!frustum.Intersects(this))
            {
                result = ContainmentType.Disjoint;
                return;
            }

            foreach (var corner in frustum.CornersInternal)
            {
                if (Contains(corner) == ContainmentType.Disjoint)
                {
                    result = ContainmentType.Intersects;
                    return;
                }
            }

            result = ContainmentType.Contains;
        }
        /// <summary>
        /// Gets a value indicating whether this <see cref="BoundingSphere"/> intersects the specified frustum.
        /// </summary>
        /// <param name="frustum">A <see cref="BoundingFrustum"/> which represents the frustum to evaluate.</param>
        /// <param name="result"><see langword="true"/> if this sphere intersects the evaluated frustum; otherwise, <see langword="false"/>.</param>
        public void Intersects(BoundingFrustum frustum, out Boolean result)
        {
            Contract.Require(frustum, nameof(frustum));

            frustum.Intersects(ref this, out result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets a value indicating whether this <see cref="Plane"/> intersects the specified frustum.
        /// </summary>
        /// <param name="frustum">A <see cref="BoundingFrustum"/> which represents the frustum to evaluate.</param>
        /// <param name="result">A <see cref="PlaneIntersectionType"/> value which describes the relationship between this plane and the evaluated frustum.</param>
        public void Intersects(BoundingFrustum frustum, out PlaneIntersectionType result)
        {
            Contract.Require(frustum, nameof(frustum));

            result = frustum.Intersects(this);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets a value indicating whether this <see cref="Plane"/> intersects the specified frustum.
        /// </summary>
        /// <param name="frustum">A <see cref="BoundingFrustum"/> which represents the frustum to evaluate.</param>
        /// <returns>A <see cref="PlaneIntersectionType"/> value which describes the relationship between this plane and the evaluated frustum.</returns>
        public PlaneIntersectionType Intersects(BoundingFrustum frustum)
        {
            Contract.Require(frustum, nameof(frustum));

            return(frustum.Intersects(this));
        }