34 lines
1.0 KiB
C#
34 lines
1.0 KiB
C#
using OpenTK.Mathematics;
|
|
using VoxelEngine.Core;
|
|
using VoxelEngine.World.Blocks;
|
|
using VoxelChunk = VoxelEngine.World.Chunk.Chunk;
|
|
|
|
namespace VoxelEngine.World.WorldGen;
|
|
|
|
// Carves caves into an already-terrain-filled chunk. Stateless after
|
|
// construction; the carve methods are pure functions of (chunk, chunkPos).
|
|
// Safe to share across worker threads.
|
|
public sealed class CaveCarver
|
|
{
|
|
private readonly int _seed;
|
|
private readonly BlockRegistry _blocks;
|
|
private readonly Configuration _cfg;
|
|
private readonly FastNoiseLite _caveNoise;
|
|
|
|
public CaveCarver(int seed, BlockRegistry blocks, Configuration cfg)
|
|
{
|
|
this._seed = seed;
|
|
this._blocks = blocks;
|
|
this._cfg = cfg;
|
|
|
|
this._caveNoise = new FastNoiseLite(seed + 100);
|
|
this._caveNoise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
|
this._caveNoise.SetFrequency(cfg.CaveNoiseFrequency);
|
|
}
|
|
|
|
public void Carve(VoxelChunk chunk, Vector3i chunkPos)
|
|
{
|
|
// Implemented in Tasks 5 and 6.
|
|
}
|
|
}
|