Beispiel #1
0
            void SplitHulls(NativeArray <TessHull> hulls, ref int hullCount, NativeArray <float2> points,
                            TessEvent evt)
            {
                int      index = GetLowerEqualHullForEvent(hulls, hullCount, evt);
                TessHull hull  = hulls[index];

                TessHull newHull;

                newHull.a   = evt.a;
                newHull.b   = evt.b;
                newHull.idx = evt.idx;

                int y = hull.iuarray[hull.iucount - 1];

                newHull.iuarray = new ArraySlice <int>(m_IUArray, newHull.idx * m_NumPoints, m_NumPoints);
                newHull.iucount = hull.iucount;
                for (int i = 0; i < newHull.iucount; ++i)
                {
                    newHull.iuarray[i] = hull.iuarray[i];
                }
                hull.iuarray[0] = y;
                hull.iucount    = 1;
                hulls[index]    = hull;

                newHull.ilarray    = new ArraySlice <int>(m_ILArray, newHull.idx * m_NumPoints, m_NumPoints);
                newHull.ilarray[0] = y;
                newHull.ilcount    = 1;

                InsertHull(hulls, index + 1, ref hullCount, newHull);
            }
Beispiel #2
0
            static float FindSplit(TessHull hull, TessEvent edge)
            {
                float d = 0;

                if (hull.a.x < edge.a.x)
                {
                    d = TessUtils.OrientFast(hull.a, hull.b, edge.a);
                }
                else
                {
                    d = TessUtils.OrientFast(edge.b, edge.a, hull.a);
                }

                if (0 != d)
                {
                    return(d);
                }

                if (edge.b.x < hull.b.x)
                {
                    d = TessUtils.OrientFast(hull.a, hull.b, edge.b);
                }
                else
                {
                    d = TessUtils.OrientFast(edge.b, edge.a, hull.b);
                }

                if (0 != d)
                {
                    return(d);
                }

                return(hull.idx - edge.idx);
            }
Beispiel #3
0
 static void InsertHull(NativeArray <TessHull> Hulls, int Pos, ref int Count, TessHull Value)
 {
     if (Count < Hulls.Length - 1)
     {
         for (int i = Count; i > Pos; --i)
         {
             Hulls[i] = Hulls[i - 1];
         }
         Hulls[Pos] = Value;
         Count++;
     }
 }
Beispiel #4
0
            void AddPoint(NativeArray <TessHull> hulls, int hullCount, NativeArray <float2> points, float2 p,
                          int idx)
            {
                int l = GetLowerHullForVector(hulls, hullCount, p);
                int u = GetUpperHullForVector(hulls, hullCount, p);

                for (int i = l; i < u; ++i)
                {
                    TessHull hull = hulls[i];

                    int m = hull.ilcount;
                    while (m > 1 && TessUtils.OrientFast(points[hull.ilarray[m - 2]], points[hull.ilarray[m - 1]], p) >
                           0)
                    {
                        TessCell c = new TessCell();
                        c.a = hull.ilarray[m - 1];
                        c.b = hull.ilarray[m - 2];
                        c.c = idx;
                        m_Cells[m_CellCount++] = c;
                        m -= 1;
                    }

                    hull.ilcount    = m + 1;
                    hull.ilarray[m] = idx;

                    m = hull.iucount;
                    while (m > 1 && TessUtils.OrientFast(points[hull.iuarray[m - 2]], points[hull.iuarray[m - 1]], p) <
                           0)
                    {
                        TessCell c = new TessCell();
                        c.a = hull.iuarray[m - 2];
                        c.b = hull.iuarray[m - 1];
                        c.c = idx;
                        m_Cells[m_CellCount++] = c;
                        m -= 1;
                    }

                    hull.iucount    = m + 1;
                    hull.iuarray[m] = idx;

                    hulls[i] = hull;
                }
            }
Beispiel #5
0
            void MergeHulls(NativeArray <TessHull> hulls, ref int hullCount, NativeArray <float2> points,
                            TessEvent evt)
            {
                float2 temp = evt.a;

                evt.a = evt.b;
                evt.b = temp;
                int index = GetEqualHullForEvent(hulls, hullCount, evt);

                TessHull upper = hulls[index];
                TessHull lower = hulls[index - 1];

                lower.iucount = upper.iucount;
                for (int i = 0; i < lower.iucount; ++i)
                {
                    lower.iuarray[i] = upper.iuarray[i];
                }

                hulls[index - 1] = lower;
                EraseHull(hulls, index, ref hullCount);
            }
Beispiel #6
0
 static float TestPoint(TessHull hull, float2 point)
 {
     return(TessUtils.OrientFast(hull.a, hull.b, point));
 }