Esempio n. 1
0
        /// <summary>
        /// Checks whether the current BoundingFrustumD intersects a BoundingBoxD.
        /// </summary>
        /// <param name="box">The BoundingBoxD to check for intersection with.</param><param name="result">[OutAttribute] true if the BoundingFrustumD and BoundingBoxD intersect; false otherwise.</param>
        public void Intersects(ref BoundingBoxD box, out bool result)
        {
            if (this.gjk == null)
            {
                this.gjk = new GjkD();
            }
            this.gjk.Reset();
            Vector3D result1;

            Vector3D.Subtract(ref this.cornerArray[0], ref box.Min, out result1);
            if ((double)result1.LengthSquared() < 9.99999974737875E-06)
            {
                Vector3D.Subtract(ref this.cornerArray[0], ref box.Max, out result1);
            }
            double num1 = double.MaxValue;

            result = false;
            double num2;

            do
            {
                Vector3D v;
                v.X = -result1.X;
                v.Y = -result1.Y;
                v.Z = -result1.Z;
                Vector3D result2;
                this.SupportMapping(ref v, out result2);
                Vector3D result3;
                box.SupportMapping(ref result1, out result3);
                Vector3D result4;
                Vector3D.Subtract(ref result2, ref result3, out result4);
                if ((double)result1.X * (double)result4.X + (double)result1.Y * (double)result4.Y + (double)result1.Z * (double)result4.Z > 0.0)
                {
                    return;
                }
                this.gjk.AddSupportPoint(ref result4);
                result1 = this.gjk.ClosestPoint;
                double num3 = num1;
                num1 = result1.LengthSquared();
                if ((double)num3 - (double)num1 <= 9.99999974737875E-06 * (double)num3)
                {
                    return;
                }
                num2 = 4E-05f * this.gjk.MaxLengthSquared;
            }while (!this.gjk.FullSimplex && (double)num1 >= (double)num2);
            result = true;
        }
Esempio n. 2
0
        public void Intersects(ref BoundingBoxD box, out bool result)
        {
            Vector3D closestPoint;
            Vector3D vectord2;
            Vector3D vectord3;
            Vector3D vectord4;
            Vector3D vectord5;

            if (this.gjk == null)
            {
                this.gjk = new GjkD();
            }
            this.gjk.Reset();
            Vector3D.Subtract(ref this.cornerArray[0], ref box.Min, out closestPoint);
            if (closestPoint.LengthSquared() < 9.99999974737875E-06)
            {
                Vector3D.Subtract(ref this.cornerArray[0], ref box.Max, out closestPoint);
            }
            double maxValue = double.MaxValue;

            result = false;
Label_0070:
            vectord2.X = -closestPoint.X;
            vectord2.Y = -closestPoint.Y;
            vectord2.Z = -closestPoint.Z;
            this.SupportMapping(ref vectord2, out vectord3);
            box.SupportMapping(ref closestPoint, out vectord4);
            Vector3D.Subtract(ref vectord3, ref vectord4, out vectord5);
            if ((((closestPoint.X * vectord5.X) + (closestPoint.Y * vectord5.Y)) + (closestPoint.Z * vectord5.Z)) <= 0.0)
            {
                this.gjk.AddSupportPoint(ref vectord5);
                closestPoint = this.gjk.ClosestPoint;
                double num3 = maxValue;
                maxValue = closestPoint.LengthSquared();
                if ((num3 - maxValue) > (9.99999974737875E-06 * num3))
                {
                    double num2 = 3.9999998989515007E-05 * this.gjk.MaxLengthSquared;
                    if (!this.gjk.FullSimplex && (maxValue >= num2))
                    {
                        goto Label_0070;
                    }
                    result = true;
                }
            }
        }