示例#1
0
        bool AddPoint(NativeArray <UHull> hulls, int hullCount, NativeArray <float2> points, float2 p, int idx)
        {
            int l = UTess.GetLower(hulls, hullCount, p, new TestHullPointL());
            int u = UTess.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 && UTess.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 && UTess.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);
        }