// Before Slice - Get smallest polygon which does not have balls in it Polygon2D GetCutPolygon(Slice2D sliceResult) { double area = 1e+10f; Polygon2D CutObject = null; foreach (Polygon2D poly in sliceResult.polygons) { if (poly.GetArea() < area && ThinSliceBall.PolygonHasBallsInside(poly) == false) { CutObject = poly; area = poly.GetArea(); } } return(CutObject); }
// After Slice - Get smallest polygon which does not have balls in it GameObject GetCutGameObject(Slice2D sliceResult) { double area = 1e+10f; GameObject CutObject = null; foreach (GameObject resultObject in sliceResult.gameObjects) { Polygon2D poly = Polygon2DList.CreateFromGameObject(resultObject)[0]; if (poly.GetArea() < area && ThinSliceBall.PolygonHasBallsInside(poly.ToWorldSpace(resultObject.transform)) == false) { CutObject = resultObject; area = poly.GetArea(); } } return(CutObject); }