private static void CalculateIntersections(Vertices polygon1, Vertices polygon2, out Vertices slicedPoly1, out Vertices slicedPoly2) { slicedPoly1 = new Vertices(polygon1); slicedPoly2 = new Vertices(polygon2); for (int i = 0; i < polygon1.Count; i++) { TSVector2 tSVector = polygon1[i]; TSVector2 tSVector2 = polygon1[polygon1.NextIndex(i)]; for (int j = 0; j < polygon2.Count; j++) { TSVector2 tSVector3 = polygon2[j]; TSVector2 tSVector4 = polygon2[polygon2.NextIndex(j)]; TSVector2 tSVector5; bool flag = LineTools.LineIntersect(tSVector, tSVector2, tSVector3, tSVector4, out tSVector5); if (flag) { FP alpha = YuPengClipper.GetAlpha(tSVector, tSVector2, tSVector5); bool flag2 = alpha > 0f && alpha < 1f; if (flag2) { int num = slicedPoly1.IndexOf(tSVector) + 1; while (num < slicedPoly1.Count && YuPengClipper.GetAlpha(tSVector, tSVector2, slicedPoly1[num]) <= alpha) { num++; } slicedPoly1.Insert(num, tSVector5); } alpha = YuPengClipper.GetAlpha(tSVector3, tSVector4, tSVector5); bool flag3 = alpha > 0f && alpha < 1f; if (flag3) { int num2 = slicedPoly2.IndexOf(tSVector3) + 1; while (num2 < slicedPoly2.Count && YuPengClipper.GetAlpha(tSVector3, tSVector4, slicedPoly2[num2]) <= alpha) { num2++; } slicedPoly2.Insert(num2, tSVector5); } } } } for (int k = 0; k < slicedPoly1.Count; k++) { int index = slicedPoly1.NextIndex(k); bool flag4 = (slicedPoly1[index] - slicedPoly1[k]).LengthSquared() <= YuPengClipper.ClipperEpsilonSquared; if (flag4) { slicedPoly1.RemoveAt(k); k--; } } for (int l = 0; l < slicedPoly2.Count; l++) { int index2 = slicedPoly2.NextIndex(l); bool flag5 = (slicedPoly2[index2] - slicedPoly2[l]).LengthSquared() <= YuPengClipper.ClipperEpsilonSquared; if (flag5) { slicedPoly2.RemoveAt(l); l--; } } }