public static Polygon PolygonWithSource(PolygonSource polygonSource) { Polygon rootPolygon = Polygon.PolygonWithPointTransforms(polygonSource.pointTransforms, polygonSource.windingDirection); // Collect sub-olygons if any. foreach (Transform eachChildTransform in polygonSource.gameObject.transform) { GameObject eachChildGameObject = eachChildTransform.gameObject; PolygonSource eachChildPolygonSource = eachChildGameObject.GetComponent <PolygonSource>(); if (eachChildPolygonSource != null) { Polygon eachSubPolygon = Polygon.PolygonWithSource(eachChildPolygonSource); eachChildPolygonSource.polygon = eachSubPolygon; // Inject into source rootPolygon.AddPolygon(eachSubPolygon); } } return(rootPolygon); }
/* * * Model updates * */ public void UpdatePointPositionsWithSource(PolygonSource polygonSource) // Assuming unchanged point count { UpdatePointPositionsWithTransforms(polygonSource.pointTransforms); }