Ejemplo n.º 1
0
 private void Update()
 {
     if (isDirty)
     {
         meshFilter.sharedMesh = MarchingSquares.CreateMesh(_densities, chunkSize, isolevel);
         isDirty = false;
     }
 }
Ejemplo n.º 2
0
        private void Start()
        {
            _densities = new NativeArray <float>((chunkSize + 1) * (chunkSize + 1), Allocator.Persistent);
            for (int y = 0; y < chunkSize + 1; y++)
            {
                for (int x = 0; x < chunkSize + 1; x++)
                {
                    int   index   = y * (chunkSize + 1) + x;
                    float density = noise.snoise((new float2(x, y) + noiseOffset) * 0.1f);
                    _densities[index] = density;
                }
            }

            meshFilter.sharedMesh = MarchingSquares.CreateMesh(_densities, chunkSize, isolevel);
        }