// Construct a quadtree of chunks (even though the chunks end up 3D, they start out 2D in the quadtree and are later projected onto a sphere) public void ConstructTree() { // Resets the mesh vertices.Clear(); triangles.Clear(); normals.Clear(); borderVertices.Clear(); borderTriangles.Clear(); visibleChildren.Clear(); mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32; // Extend the resolution capabilities of the mesh // Generate chunks parentChunk = new TerrainChunk(1, planetScript, this, null, localUp.normalized * planetScript.size, radius, 0, localUp, axisA, axisB, new byte[4], 0, devMode); parentChunk.GenerateChildren(); // Get chunk mesh data int triangleOffset = 0; int borderTriangleOffset = 0; parentChunk.GetVisibleChildren(); foreach (TerrainChunk child in visibleChildren) { child.GetNeighbourLOD(); (Vector3[], int[], int[], Vector3[], Vector3[])verticesAndTriangles = child.CalculateVerticesAndTriangles(triangleOffset, borderTriangleOffset);