예제 #1
0
 /// <summary>
 /// 检查这个平面是否与指定包围盒相交
 /// </summary>
 /// <param name="box">指定的包围盒</param>
 /// <param name="result">[输出属性] 表明关系的枚举类型</param>
 public void Intersects(ref BoundingBox box, out PlaneIntersectionStatus result)
 {
     Vector3 vector;
     Vector3 vector2;
     vector2.X = (this.Normal.X >= 0f) ? box.Min.X : box.Max.X;
     vector2.Y = (this.Normal.Y >= 0f) ? box.Min.Y : box.Max.Y;
     vector2.Z = (this.Normal.Z >= 0f) ? box.Min.Z : box.Max.Z;
     vector.X = (this.Normal.X >= 0f) ? box.Max.X : box.Min.X;
     vector.Y = (this.Normal.Y >= 0f) ? box.Max.Y : box.Min.Y;
     vector.Z = (this.Normal.Z >= 0f) ? box.Max.Z : box.Min.Z;
     float num = ((this.Normal.X * vector2.X) + (this.Normal.Y * vector2.Y)) + (this.Normal.Z * vector2.Z);
     if ((num + this.D) > 0f)
     {
         result = PlaneIntersectionStatus.Front;
     }
     else
     {
         num = ((this.Normal.X * vector.X) + (this.Normal.Y * vector.Y)) + (this.Normal.Z * vector.Z);
         if ((num + this.D) < 0f)
         {
             result = PlaneIntersectionStatus.Back;
         }
         else
         {
             result = PlaneIntersectionStatus.Intersecting;
         }
     }
 }
예제 #2
0
        /// <summary>
        /// 检查当前包围盒是否与指定平面相交
        /// </summary>
        /// <param name="plane">指定的平面</param>
        /// <param name="result">[输出属性] 枚举类型表明包围盒与平面是否相交</param>
        public void Intersects(ref Plane plane, out PlaneIntersectionStatus result)
        {
            Vector3 vector;
            Vector3 vector2;

            vector2.X = (plane.Normal.X >= 0f) ? this.Min.X : this.Max.X;
            vector2.Y = (plane.Normal.Y >= 0f) ? this.Min.Y : this.Max.Y;
            vector2.Z = (plane.Normal.Z >= 0f) ? this.Min.Z : this.Max.Z;
            vector.X  = (plane.Normal.X >= 0f) ? this.Max.X : this.Min.X;
            vector.Y  = (plane.Normal.Y >= 0f) ? this.Max.Y : this.Min.Y;
            vector.Z  = (plane.Normal.Z >= 0f) ? this.Max.Z : this.Min.Z;
            float num = ((plane.Normal.X * vector2.X) + (plane.Normal.Y * vector2.Y)) + (plane.Normal.Z * vector2.Z);

            if ((num + plane.D) > 0f)
            {
                result = PlaneIntersectionStatus.Front;
            }
            else
            {
                num = ((plane.Normal.X * vector.X) + (plane.Normal.Y * vector.Y)) + (plane.Normal.Z * vector.Z);
                if ((num + plane.D) < 0f)
                {
                    result = PlaneIntersectionStatus.Back;
                }
                else
                {
                    result = PlaneIntersectionStatus.Intersecting;
                }
            }
        }
예제 #3
0
 /// <summary>
 /// 检查这个平面是否与指定包围球相交
 /// </summary>
 /// <param name="sphere">指定的包围球</param>
 /// <param name="result">表明关系的枚举类型</param>
 public void Intersects(ref BoundingSphere sphere, out PlaneIntersectionStatus result)
 {
     float num2 = ((sphere.Center.X * this.Normal.X) + (sphere.Center.Y * this.Normal.Y)) + (sphere.Center.Z * this.Normal.Z);
     float num = num2 + this.D;
     if (num > sphere.Radius)
     {
         result = PlaneIntersectionStatus.Front;
     }
     else if (num < -sphere.Radius)
     {
         result = PlaneIntersectionStatus.Back;
     }
     else
     {
         result = PlaneIntersectionStatus.Intersecting;
     }
 }
        /// <summary>
        /// 检测当前平截头体是否与指定的平面相交
        /// </summary>
        /// <param name="box">要检测的平面</param>
        /// <param name="result">[输出参数] 指示是否相交的枚举</param>
        public void Intersects(ref Plane plane, out PlaneIntersectionStatus result)
        {
            int num = 0;

            for (int i = 0; i < 8; i++)
            {
                float num3;
                Vector3.Dot(ref this.cornerArray[i], ref plane.Normal, out num3);
                if ((num3 + plane.D) > 0f)
                {
                    num |= 1;
                }
                else
                {
                    num |= 2;
                }
                if (num == 3)
                {
                    result = PlaneIntersectionStatus.Intersecting;
                    return;
                }
            }
            result = (num == 1) ? PlaneIntersectionStatus.Front : PlaneIntersectionStatus.Back;
        }
예제 #5
0
 /// <summary>
 /// 检查当前包围球是否与指定平面相交
 /// </summary>
 /// <param name="plane">指定平面</param>
 /// <param name="result">[输出属性] 表明关系的枚举类型</param>
 public void Intersects(ref Plane plane, out PlaneIntersectionStatus result)
 {
     plane.Intersects(ref this, out result);
 }