Exemplo n.º 1
0
 public static bool Overlap(AABB a, AABB b)
 {
     return a.Intersects(b);
 }
Exemplo n.º 2
0
        public static bool IntersectsLine_Fast(AABB a, Vector2 lineStart, Vector2 lineEnd)
        {
            if (a.Intersects(lineStart) || a.Intersects(lineEnd)) { return true; }

            LineSegment te, re, be, le;
            te = new LineSegment(new Vector2(a.Left, a.Top), new Vector2(a.Right, a.Top));
            re = new LineSegment(new Vector2(a.Right, a.Top), new Vector2(a.Right, a.Bottom));
            be = new LineSegment(new Vector2(a.Right, a.Bottom), new Vector2(a.Left, a.Bottom));
            le = new LineSegment(new Vector2(a.Left, a.Bottom), new Vector2(a.Left, a.Top));

            return (Collider.LinesIntersect_Fast(lineStart, lineEnd, te.start, te.end) ||
                Collider.LinesIntersect_Fast(lineStart, lineEnd, re.start, re.end) ||
                Collider.LinesIntersect_Fast(lineStart, lineEnd, be.start, be.end) ||
                Collider.LinesIntersect_Fast(lineStart, lineEnd, le.start, le.end));
        }