public static List <List <int> > Decompose(EarPolygon poly, ref List <Vector2> vert) { EarClipping.Clip(poly); List <Vector2> triangles = new List <Vector2>(); GeoUtils.FlatList(poly.mResults, ref triangles); List <int> indices = new List <int>(); GeoUtils.MeshVertexPrimitiveType(triangles, ref vert, ref indices); return(HMDecompose(vert, indices)); }
/// <summary> /// 简单多边形或者三角面点数组 /// </summary> /// <param name="tries"></param> /// <param name="isPolygon">是否为简单多边形</param> /// <param name="vert"></param> /// <returns></returns> public static List <List <int> > Decompose(List <Vector2> tries, bool isPolygon, ref List <Vector2> vert) { if (isPolygon) { EarPolygon poly = new EarPolygon(); foreach (Vector2 v in tries) { poly.AddPoint(v.x, v.y); } EarClipping.Clip(poly); List <Vector2> triangles = new List <Vector2>(); GeoUtils.FlatList(poly.mResults, ref triangles); List <int> indices = new List <int>(); GeoUtils.MeshVertexPrimitiveType(triangles, ref vert, ref indices); return(HMDecompose(vert, indices)); } else { List <int> indices = new List <int>(); GeoUtils.MeshVertexPrimitiveType(tries, ref vert, ref indices); return(HMDecompose(vert, indices)); } }