public static void CreateMeshData(float[,,] map, NativeList <int3> usedIndices, float scaleFactor, ref Mesh mesh) { if (!MarchingCubeTables.IsInitialized) { MarchingCubeTables.Initialize(); } Profiler.BeginSample("MarchingCube"); triangles.Clear(); vertices.Clear(); for (int i = 0; i < usedIndices.Length; i++) { MarchCube(usedIndices[i], map, scaleFactor, triangles, vertices); } mesh.Clear(); mesh.SetVertices(vertices); mesh.SetTriangles(triangles, 0); //might want to calculate the normal on the spot mesh.RecalculateNormals(); Profiler.EndSample(); }
private void OnDestroy() { MarchingCubeTables.Dispose(); }
private void Start() { mesh = new Mesh(); MarchingCubeTables.Initialize(); }