static public bool IntersectAABB3Sphere3(AABB3 box, Sphere3 sphere)
        {
            Vector3 center        = sphere.center;
            Vector3 min           = box.min;
            Vector3 max           = box.max;
            float   totalDistance = 0f;
            float   distance;

            if (center.x < min.x)
            {
                distance       = center.x - min.x;
                totalDistance += distance * distance;
            }
            else if (center.x > max.x)
            {
                distance       = center.x - max.x;
                totalDistance += distance * distance;
            }
            if (center.y < min.y)
            {
                distance       = center.y - min.y;
                totalDistance += distance * distance;
            }
            else if (center.y > max.y)
            {
                distance       = center.y - max.y;
                totalDistance += distance * distance;
            }
            if (center.z < min.z)
            {
                distance       = center.z - min.z;
                totalDistance += distance * distance;
            }
            else if (center.z > max.z)
            {
                distance       = center.z - max.z;
                totalDistance += distance * distance;
            }
            return(totalDistance <= sphere.radius * sphere.radius);
        }
示例#2
0
        // Token: 0x0600258C RID: 9612 RVA: 0x000BB5D0 File Offset: 0x000B97D0
        public static bool IntersectAABB3Sphere3(AABB3 box, Sphere3 sphere)
        {
            Vector3 center = sphere.center;
            Vector3 min    = box.min;
            Vector3 max    = box.max;
            float   num    = 0f;

            if (center.x < min.x)
            {
                float num2 = center.x - min.x;
                num += num2 * num2;
            }
            else if (center.x > max.x)
            {
                float num2 = center.x - max.x;
                num += num2 * num2;
            }
            if (center.y < min.y)
            {
                float num2 = center.y - min.y;
                num += num2 * num2;
            }
            else if (center.y > max.y)
            {
                float num2 = center.y - max.y;
                num += num2 * num2;
            }
            if (center.z < min.z)
            {
                float num2 = center.z - min.z;
                num += num2 * num2;
            }
            else if (center.z > max.z)
            {
                float num2 = center.z - max.z;
                num += num2 * num2;
            }
            return(num <= sphere.radius * sphere.radius);
        }