Ejemplo n.º 1
0
        public static ViewClipShape FromPoints(Vector2 point1, Vector2 point2, Vector2 point3, Vector2 point4, Vector2 point5, Vector2 point6)
        {
            var shape = new ViewClipShape(point1, point2, point3, point4, point5, point6);

            shape.BuildAxis();
            return(shape);
        }
Ejemplo n.º 2
0
        internal static bool Intersects(ref Rectangle shape1, ref ViewClipShape shape2)
        {
            int min, max;

            //Check against rectangle axis
            Project(shape1.Axis1, ref shape2, out min, out max);
            if (shape1.A1Min > max || shape1.A1Max < min)
            {
                return(false);
            }

            Project(shape1.Axis2, ref shape2, out min, out max);
            if (shape1.A2Min > max || shape1.A2Max < min)
            {
                return(false);
            }

            //Check against the viewclipshape axis - thre are at least 3
            for (var i = 0; i < shape2.Count; i++)
            {
                Project(shape2.GetAxis(i), ref shape1, out min, out max);
                if (shape2.GetMinScalar(i) > max || shape2.GetMaxScalar(i) < min)
                {
                    return(false);
                }
            }

            return(true);
        }
Ejemplo n.º 3
0
        internal static void Project(Vector2 axis, ref ViewClipShape shape, out int min, out int max)
        {
            min = GenerateScalar(shape.Point1, ref axis);
            max = min;

            var current = GenerateScalar(shape.Point2, ref axis);

            if (current <= min)
            {
                min = current;
            }
            else
            if (current > max)
            {
                max = current;
            }

            current = GenerateScalar(shape.Point3, ref axis);

            if (current <= min)
            {
                min = current;
            }
            else
            if (current > max)
            {
                max = current;
            }

            if (shape.Count < 4)
            {
                return;
            }
            current = GenerateScalar(shape.Point4, ref axis);

            if (current <= min)
            {
                min = current;
            }
            else if (current > max)
            {
                max = current;
            }

            if (shape.Count < 5)
            {
                return;
            }
            current = GenerateScalar(shape.Point5, ref axis);

            if (current <= min)
            {
                min = current;
            }
            else if (current > max)
            {
                max = current;
            }

            if (shape.Count < 6)
            {
                return;
            }
            current = GenerateScalar(shape.Point6, ref axis);

            if (current <= min)
            {
                min = current;
            }
            else if (current > max)
            {
                max = current;
            }
        }
Ejemplo n.º 4
0
 public bool Intersects(ViewClipShape shape)
 {
     return(Intersection.Intersects(ref this, ref shape));
 }