Ejemplo n.º 1
0
        bool AddPoint(NativeArray <UHull> hulls, int hullCount, NativeArray <float2> points, float2 p, int idx)
        {
            int l = ModuleHandle.GetLower(hulls, hullCount, p, new TestHullPointL());
            int u = ModuleHandle.GetUpper(hulls, hullCount, p, new TestHullPointU());

            if (l < 0 || u < 0)
            {
                return(false);
            }
            for (int i = l; i < u; ++i)
            {
                UHull hull = hulls[i];

                int m = hull.ilcount;
                while (m > 1 && ModuleHandle.OrientFast(points[hull.ilarray[m - 2]], points[hull.ilarray[m - 1]], p) > 0)
                {
                    int3 c = new int3();
                    c.x = hull.ilarray[m - 1];
                    c.y = hull.ilarray[m - 2];
                    c.z = idx;
                    m_Cells[m_CellCount++] = c;
                    m -= 1;
                }

                hull.ilcount = m + 1;
                if (hull.ilcount > hull.ilarray.Length)
                {
                    return(false);
                }
                hull.ilarray[m] = idx;

                m = hull.iucount;
                while (m > 1 && ModuleHandle.OrientFast(points[hull.iuarray[m - 2]], points[hull.iuarray[m - 1]], p) < 0)
                {
                    int3 c = new int3();
                    c.x = hull.iuarray[m - 2];
                    c.y = hull.iuarray[m - 1];
                    c.z = idx;
                    m_Cells[m_CellCount++] = c;
                    m -= 1;
                }

                hull.iucount = m + 1;
                if (hull.iucount > hull.iuarray.Length)
                {
                    return(false);
                }
                hull.iuarray[m] = idx;

                hulls[i] = hull;
            }
            return(true);
        }
Ejemplo n.º 2
0
        bool SplitHulls(NativeArray <UHull> hulls, ref int hullCount, NativeArray <float2> points, UEvent evt)
        {
            int index = ModuleHandle.GetLower(hulls, hullCount, evt, new TestHullEventLe());

            if (index < 0)
            {
                return(false);
            }

            UHull hull = hulls[index];

            UHull 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_NumHulls, m_NumHulls);
            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_NumHulls, m_NumHulls);
            newHull.ilarray[0] = y;
            newHull.ilcount    = 1;

            InsertHull(hulls, index + 1, ref hullCount, newHull);
            return(true);
        }