public void Step() { MeshUtility temp = new MeshUtility(); setCoef(util.Vertices.Count); List <Vertex> vs = new List <Vertex>(); //Centers foreach (Triangle t in util.Triangles) { Vertex vert = new Vertex(((t.GetVertices()[0].Position + t.GetVertices()[1].Position + t.GetVertices()[2].Position) / 3)); temp.FindOrCreateVertex(vert); vs.Add(vert); } foreach (Vertex v in vs) { foreach (Vertex v2 in vs) { if (v != v2) { temp.FindOrCreateEdge(v, v2); } } } List <Edge> edges = new List <Edge>(); foreach (Edge e in temp.Edges) { edges.Add(e); } foreach (Edge e in edges) { foreach (Vertex v in vs) { if (v != e.Vertices[0] && v != e.Vertices[1] && e.Vertices[0] != e.Vertices[1]) { temp.CreateTriangle(v, e.Vertices[0], e.Vertices[1]); } } } foreach (Triangle t in util.Triangles) { Vector3 vt = getVertexPoint(t); temp.FindOrCreateVertex(vt); } //foreach (Vertex v in util.Vertices) //{ // for (int j = 0; j < v.GetTriangles().Length; j++) // { // Triangle t = v.GetTriangles()[j]; // Triangle tnext = null; // int i = 0; // do // { // if (i > v.GetTriangles().Length) // tnext = null; // else // tnext = v.GetTriangles()[i]; // temp.CreateTriangle(tnext.GetVertices()[0], tnext.GetVertices()[1], tnext.GetVertices()[2]); // t = tnext; // i++; // } while (t != v.GetTriangles()[j] && t != null); // } //} Debug.Log(temp.Vertices.Count); Debug.Log(temp.Edges.Count); Debug.Log(temp.Triangles.Count); util = temp; DebugGraph.meshUtility = util; filter.sharedMesh = util.ToMesh(); }