Exemple #1
0
        public override object Clone()
        {
            TriangleMask mask = new TriangleMask(_p0, _p1, _p2);
            mask._pos = _pos;

            return mask;
        }
Exemple #2
0
 public static bool TestOverlapEdge(TriangleMask triMask, AYLine ylMAsk)
 {
     return TestOverlapEdge(ylMAsk, triMask);
 }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
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);
        }
Exemple #7
0
 public static bool TestOverlap(TriangleMask triMask, AABBMask rMask)
 {
     return TestOverlap(rMask, triMask);
 }
Exemple #8
0
 public static bool TestOverlap(TriangleMask triMask, LineMask lnMask)
 {
     return TestOverlap(lnMask, triMask);
 }
Exemple #9
0
 public static bool TestOverlap(TriangleMask triMask, AYLineMask ylMask)
 {
     return TestOverlap(ylMask, triMask);
 }
Exemple #10
0
 public static bool TestOverlap(TriangleMask triMask, AXLine xlMAsk)
 {
     return TestOverlap(xlMAsk, triMask);
 }
Exemple #11
0
 public static bool TestOverlap(TriangleMask triMask, CircleMask cMask)
 {
     return TestOverlap(cMask, triMask);
 }
Exemple #12
0
 // Triangle -- [____] Collision Tests
 public static bool TestOverlap(TriangleMask triMask, PointMask ptMask)
 {
     return TestOverlap(ptMask, triMask);
 }
Exemple #13
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);
        }
Exemple #14
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);
        }
Exemple #15
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);
        }
Exemple #16
0
        public static bool TestOverlap(CircleMask cMask, TriangleMask triMask)
        {
            VectorFP p0 = (VectorFP)cMask._pos + cMask._p;
            VectorFP p1 = triMask.ClosestPoint(p0);

            FPInt dx = p1.X - p0.X;
            FPInt dy = p1.Y - p0.Y;
            FPInt d2 = dx * dx + dy * dy;
            FPInt r2 = cMask._radius * cMask._radius;

            return (d2 < r2);
        }