static float FindSplit(UHull hull, UEvent edge) { float d = 0; if (hull.a.x < edge.a.x) { d = UTess.OrientFast(hull.a, hull.b, edge.a); } else { d = UTess.OrientFast(edge.b, edge.a, hull.a); } if (0 != d) { return(d); } if (edge.b.x < hull.b.x) { d = UTess.OrientFast(hull.a, hull.b, edge.b); } else { d = UTess.OrientFast(edge.b, edge.a, hull.b); } if (0 != d) { return(d); } return(hull.idx - edge.idx); }
public int Compare(UEvent a, UEvent b) { float f = (a.a.x - b.a.x); if (0 != f) { return((f > 0) ? 1 : -1); } f = (a.a.y - b.a.y); if (0 != f) { return((f > 0) ? 1 : -1); } int i = a.type - b.type; if (0 != i) { return(i); } if (a.type != (int)UEventType.EVENT_POINT) { float o = UTess.OrientFast(a.a, a.b, b.b); if (0 != o) { return((o > 0) ? 1 : -1); } } return(a.idx - b.idx); }
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); }
public bool Test(UHull h, float2 p, ref float t) { t = UTess.OrientFast(h.a, h.b, p); return(t > 0); }