Assets/Examples/Scripts/World.cs
/// <summary>
/// Sets the density at a world position
/// </summary>
/// <param name="density">The new density</param>
/// <param name="worldPosition">The density's world position</param>
Sets the density at a world position
Sets the density at a world position
public void SetDensity(float density, int3 worldPosition)
        {
            List<int3> modifiedChunkPositions = new List<int3>();
            for (int i = 0; i < 8; i++)
            {
                int3 chunkPos = chunkSize * WorldPositionToCoordinate(worldPosition - LookupTables.CubeCorners[i]);
                if (modifiedChunkPositions.Contains(chunkPos)) { continue; }
                if (TryGetChunk(chunkPos, out Chunk chunk))
                {
                    int3 localPos = (worldPosition - chunkPos).Mod(ChunkSize + 1);
                    chunk.SetDensity(density, localPos);
                    modifiedChunkPositions.Add(chunkPos);
                }
            }
        }
public void SetDensity ( float density , int3 worldPosition ) { List < int3 > modifiedChunkPositions = new List < int3 > ( ) ; for ( int i = 0 ; i < 8 ; i ++ ) { int3 chunkPos = chunkSize * WorldPositionToCoordinate ( worldPosition - LookupTables . CubeCorners [ i ] ) ; if ( modifiedChunkPositions . Contains ( chunkPos ) ) { continue ; } if ( TryGetChunk ( chunkPos , out Chunk chunk ) ) { int3 localPos = ( worldPosition - chunkPos ) . Mod ( ChunkSize + 1 ) ; chunk . SetDensity ( density , localPos ) ; modifiedChunkPositions . Add ( chunkPos ) ; } } }
Sets the density at a world position
Sets the density at a world position
density
float
The new density
The new density
worldPosition
int3
The density's world position
The density ' s world position