Exemplo n.º 1
0
        public static bool TestOverlap(PointMask ptMask, TriangleMask triMask)
        {
            PointFP bary = triMask.Barycentric((VectorFP)ptMask._pos + ptMask._point);

            return (bary.X > 0 && bary.Y > 0 && (bary.X + bary.Y) < 1);
        }
Exemplo n.º 2
0
        public static bool TestOverlapEdge(AYLine ylMask, TriangleMask triMask)
        {
            VectorFP a = (VectorFP)triMask._pos + triMask._p0;
            VectorFP b = (VectorFP)triMask._pos + triMask._p1;
            VectorFP c = (VectorFP)triMask._pos + triMask._p2;

            if (ylMask.IntersectsLineEdge(a, b) || ylMask.IntersectsLineEdge(b, c) || ylMask.IntersectsLineEdge(a, c)) {
                return true;
            }

            VectorFP q = triMask.Barycentric(ylMask.TopPoint);

            return (q.X >= 0 && q.Y >= 0 && (q.X + q.Y) <= 1);
        }
Exemplo n.º 3
0
        public static bool TestOverlapEdge(TriangleMask triMask, FPInt x, FPInt y)
        {
            PointFP bary = triMask.Barycentric(new VectorFP(x, y));

            return (bary.X >= 0 && bary.Y >= 0 && (bary.X + bary.Y) <= 1);
        }
Exemplo n.º 4
0
        public static bool TestOverlap(TriangleMask triMask1, TriangleMask triMask2)
        {
            VectorFP a = (VectorFP)triMask2._pos + triMask2._p0;
            VectorFP b = (VectorFP)triMask2._pos + triMask2._p1;
            VectorFP c = (VectorFP)triMask2._pos + triMask2._p2;

            VectorFP d = (VectorFP)triMask1._pos + triMask1._p0;
            VectorFP e = (VectorFP)triMask1._pos + triMask1._p1;
            VectorFP f = (VectorFP)triMask1._pos + triMask1._p2;

            if (LineMask.IntersectsLine(a, b, d, e) || LineMask.IntersectsLine(a, b, e, f) ||
                LineMask.IntersectsLine(a, b, d, f) || LineMask.IntersectsLine(b, c, d, e) ||
                LineMask.IntersectsLine(b, c, e, f) || LineMask.IntersectsLine(b, c, d, f) ||
                LineMask.IntersectsLine(a, c, d, e) || LineMask.IntersectsLine(a, c, e, f))
            {
                return true;
            }

            // Check for containment
            VectorFP q = triMask2.Barycentric(d);
            if (q.X >= 0 && q.Y >= 0 && (q.X + q.Y) <= 1) {
                return true;
            }

            q = triMask1.Barycentric(a);
            return (q.X >= 0 && q.Y >= 0 && (q.X + q.Y) <= 1);
        }
Exemplo n.º 5
0
        public static bool TestOverlap(AABBMask rMask, TriangleMask triMask)
        {
            VectorFP a = (VectorFP)triMask._pos + triMask._p0;
            VectorFP b = (VectorFP)triMask._pos + triMask._p1;
            VectorFP c = (VectorFP)triMask._pos + triMask._p2;

            if (rMask.IntersectsLine(a, b) || rMask.IntersectsLine(b, c) || rMask.IntersectsLine(a, c)) {
                return true;
            }

            VectorFP r = rMask._pos + new VectorFP(rMask._point.X + (rMask._w >> 1), rMask._point.Y + (rMask._h >> 1));
            VectorFP q = triMask.Barycentric(r);

            return (q.X >= 0 && q.Y >= 0 && (q.X + q.Y) <= 1);
        }
Exemplo n.º 6
0
        public static bool TestOverlap(LineMask lnMask, TriangleMask triMask)
        {
            VectorFP a = (VectorFP)triMask._pos + triMask._p0;
            VectorFP b = (VectorFP)triMask._pos + triMask._p1;
            VectorFP c = (VectorFP)triMask._pos + triMask._p2;

            //TestResult t = lnMask.LineIntersect(a, b);

            if (lnMask.IntersectsLine(a, b) || lnMask.IntersectsLine(b, c) || lnMask.IntersectsLine(a, c)) {
                return true;
            }

            // Check for containment
            VectorFP r = triMask.Barycentric((VectorFP)lnMask._pos + lnMask._p0);

            return (r.X >= 0 && r.Y >= 0 && (r.X + r.Y) <= 1);
        }
Exemplo n.º 7
0
        public static bool TestOverlap(AXLineMask xlMask, TriangleMask triMask)
        {
            VectorFP a = (VectorFP)triMask._pos + triMask._p0;
            VectorFP b = (VectorFP)triMask._pos + triMask._p1;
            VectorFP c = (VectorFP)triMask._pos + triMask._p2;

            if (xlMask.IntersectsLine(a, b) || xlMask.IntersectsLine(b, c) || xlMask.IntersectsLine(a, c)) {
                return true;
            }

            VectorFP q = triMask.Barycentric((VectorFP)xlMask._pos + xlMask._p);

            return (q.X >= 0 && q.Y >= 0 && (q.X + q.Y) <= 1);
        }