Ejemplo n.º 1
0
        public static void Intersects(ref BoundingSphere2 boundingSphere, ref BoundingBox2 boundingBox, out bool result)
        {
            Vector2 clampedLocation;

            if (boundingSphere.Center.X > boundingBox.Max.X)
            {
                clampedLocation.X = boundingBox.Max.X;
            }
            else if (boundingSphere.Center.X < boundingBox.Min.X)
            {
                clampedLocation.X = boundingBox.Min.X;
            }
            else
            {
                clampedLocation.X = boundingSphere.Center.X;
            }

            if (boundingSphere.Center.Y > boundingBox.Max.Y)
            {
                clampedLocation.Y = boundingBox.Max.Y;
            }
            else if (boundingSphere.Center.Y < boundingBox.Min.Y)
            {
                clampedLocation.Y = boundingBox.Min.Y;
            }
            else
            {
                clampedLocation.Y = boundingSphere.Center.Y;
            }

            result = clampedLocation.DistanceSquared(boundingSphere.Center) <= (boundingSphere.Radius * boundingSphere.Radius);
        }
Ejemplo n.º 2
0
        public static void Intersects(ref BoundingSphere2 boundingSphere, ref BoundingBox2 boundingBox, out bool result)
        {
            Vector2 clampedLocation;
            if (boundingSphere.Center.X > boundingBox.Max.X)
            {
                clampedLocation.X = boundingBox.Max.X;
            }
            else if (boundingSphere.Center.X < boundingBox.Min.X)
            {
                clampedLocation.X = boundingBox.Min.X;
            }
            else
            {
                clampedLocation.X = boundingSphere.Center.X;
            }

            if (boundingSphere.Center.Y > boundingBox.Max.Y)
            {
                clampedLocation.Y = boundingBox.Max.Y;
            }
            else if (boundingSphere.Center.Y < boundingBox.Min.Y)
            {
                clampedLocation.Y = boundingBox.Min.Y;
            }
            else
            {
                clampedLocation.Y = boundingSphere.Center.Y;
            }

            result = clampedLocation.DistanceSquared(boundingSphere.Center) <= (boundingSphere.Radius * boundingSphere.Radius);
        }
Ejemplo n.º 3
0
        public bool Intersects(BoundingSphere2 boundingSphere)
        {
            Vector2 clampedLocation;

            if (boundingSphere.Center.X > Max.X)
            {
                clampedLocation.X = Max.X;
            }
            else if (boundingSphere.Center.X < Min.X)
            {
                clampedLocation.X = Min.X;
            }
            else
            {
                clampedLocation.X = boundingSphere.Center.X;
            }

            if (boundingSphere.Center.Y > Max.Y)
            {
                clampedLocation.Y = Max.Y;
            }
            else if (boundingSphere.Center.Y < Min.Y)
            {
                clampedLocation.Y = Min.Y;
            }
            else
            {
                clampedLocation.Y = boundingSphere.Center.Y;
            }

            return(clampedLocation.DistanceSquared(boundingSphere.Center) <= (boundingSphere.Radius * boundingSphere.Radius));
        }
Ejemplo n.º 4
0
        public bool Intersects(BoundingSphere2 boundingSphere)
        {
            Vector2 clampedLocation;
            if (boundingSphere.Center.X > Max.X)
            {
                clampedLocation.X = Max.X;
            }
            else if (boundingSphere.Center.X < Min.X)
            {
                clampedLocation.X = Min.X;
            }
            else
            {
                clampedLocation.X = boundingSphere.Center.X;
            }

            if (boundingSphere.Center.Y > Max.Y)
            {
                clampedLocation.Y = Max.Y;
            }
            else if (boundingSphere.Center.Y < Min.Y)
            {
                clampedLocation.Y = Min.Y;
            }
            else
            {
                clampedLocation.Y = boundingSphere.Center.Y;
            }

            return clampedLocation.DistanceSquared(boundingSphere.Center) <= (boundingSphere.Radius * boundingSphere.Radius);
        }