예제 #1
0
        static void ResetClearance(double2 o, double2 d, Edge *t, float2 perp)
        {
            var rhs = t->LPrev;
            var lhs = t->LNext->Sym;
            var a   = rhs->Dest->Point;
            var b   = rhs->Org->Point;
            var c   = lhs->Dest->Point;
            var f   = Math.ProjectSeg2(o, d, b, out var bi);

            if (f >= 0 && f <= 1 &&
                !lhs->Constrained && !rhs->Constrained &&
                math.lengthsq(bi - b) < math.min(math.lengthsq(a - b), math.lengthsq(c - b)))
            {
                lhs->ClearanceLeft  = -1;
                rhs->ClearanceRight = -1;
            }

            if (f >= 0 && !rhs->Constrained)
            {
                var r = Math.IntersectLineSegClamped(o, o + perp, b, (a + b) / 2);
                Math.ProjectSeg2(o, d, r, out var ri);
                if (math.lengthsq(ri - r) < math.min(math.lengthsq(b - r), math.lengthsq(a - r)))
                {
                    ResetClearance(o, d, rhs->Sym, perp);
                }
            }

            if (f <= 1 && !lhs->Constrained)
            {
                var l = Math.IntersectLineSegClamped(d, d + perp, b, (c + b) / 2);
                Math.ProjectSeg2(o, d, l, out var li);
                if (math.lengthsq(li - l) < math.min(math.lengthsq(b - l), math.lengthsq(c - l)))
                {
                    ResetClearance(o, d, lhs, perp);
                }
            }
        }