public static bool IsIntersect(Poly poly, int x, int z) { Vector2 pA = new Vector2(left + tileSize * x, bottom + tileSize * z); Vector2 pB = new Vector2(left + tileSize * (x + 1), bottom + tileSize * z); Vector2 pC = new Vector2(left + tileSize * (x + 1), bottom + tileSize * (z + 1)); Vector2 pD = new Vector2(left + tileSize * x, bottom + tileSize * (z + 1)); Geo2D poly2d = poly.GetGeo2D(); Geo2D rect2d = new Geo2D(pA, pB, pC, pD); return(GraphTester2D.IsIntersect(poly2d, rect2d)); }
protected int GetPoly(Vector2 pos, List <int> plys) { foreach (int i in plys) { Poly p = polys[i]; if (GraphTester2D.IsInside(pos, p.GetGeo2D())) { return(i); } } return(-1); }
public static bool CouldMerge(ref Poly toPoly, Poly mergeTri, GeoEdge sharedEdge) { bool couldmerge = true; Vector3 a = toPoly.RelatedEdgeExtrude(sharedEdge.A, sharedEdge).OtherPoint(sharedEdge.A); Vector3 b = sharedEdge.PointA; Vector3 c = mergeTri.RelatedEdgeExtrude(sharedEdge.A, sharedEdge).OtherPoint(sharedEdge.A); Vector3 d = sharedEdge.OtherPoint(sharedEdge.A); couldmerge &= GraphTester2D.TotalAngleForThreeSeg(a, b, c, d) - 180f < 1e-06; a = toPoly.RelatedEdgeExtrude(sharedEdge.B, sharedEdge).OtherPoint(sharedEdge.B); b = sharedEdge.PointB; c = mergeTri.RelatedEdgeExtrude(sharedEdge.B, sharedEdge).OtherPoint(sharedEdge.B); d = sharedEdge.OtherPoint(sharedEdge.B); couldmerge &= GraphTester2D.TotalAngleForThreeSeg(a, b, c, d) - 180f < 1e-06; return(couldmerge); }