Terrain feel: biome regions ~10x larger (Voronoi cell size 96->960); terrain height now eases across biome borders via a Voronoi distance blend (smooth, and ~25x cheaper than the old 169-sample box blur); mountains capped to ~2/3 world height and gentled (ridged amplitude/frequency lowered), snow line lowered to match. Centralization: ~27 world-gen/render tuning constants (biome amplitudes & frequencies, climate-noise frequencies/octaves, biome-selection thresholds, blend width, cell size, filler depth, snow line, camera near plane, spawn offset, overlay scale) hoisted from scattered literals into a region-organized, fully-commented Configuration. Configuration is threaded into NoiseSource, the biomes, BiomeRegistry, BiomeMap (+Classify), TerrainSampler, WorldGenerator (+BlockAt filler depth), and Camera via Player. Defaults equal the prior values, so generation is unchanged; worldgen tests updated for the new constructor signatures.
56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using VoxelEngine.Core;
|
|
using VoxelEngine.World.Blocks;
|
|
using VoxelEngine.World.WorldGen;
|
|
using Xunit;
|
|
|
|
namespace VoxelEngine.Tests.WorldGen;
|
|
|
|
public class BiomeMapTests
|
|
{
|
|
private static (BiomeMap map, BiomeRegistry biomes) Build(int seed = 42)
|
|
{
|
|
var blocks = new BlockRegistry();
|
|
var biomes = new BiomeRegistry(seed, blocks, new Configuration());
|
|
var noise = new NoiseSource(seed, new Configuration());
|
|
var cells = new VoronoiCells(seed, 96f);
|
|
return (new BiomeMap(noise, cells, biomes, new Configuration()), biomes);
|
|
}
|
|
|
|
[Fact]
|
|
public void Classify_HighElevation_IsMountains()
|
|
{
|
|
var (_, biomes) = Build();
|
|
Assert.Same(biomes.Mountains, BiomeMap.Classify(0f, 0.5f, 0f, biomes, new Configuration()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Classify_HotLowElevation_IsDesert()
|
|
{
|
|
var (_, biomes) = Build();
|
|
Assert.Same(biomes.Desert, BiomeMap.Classify(0.5f, 0f, 0f, biomes, new Configuration()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Classify_TemperateWooded_IsForest()
|
|
{
|
|
var (_, biomes) = Build();
|
|
Assert.Same(biomes.Forest, BiomeMap.Classify(0f, 0f, 0.5f, biomes, new Configuration()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Classify_ColdLow_IsPlains()
|
|
{
|
|
var (_, biomes) = Build();
|
|
Assert.Same(biomes.Plains, BiomeMap.Classify(-0.9f, 0f, 0f, biomes, new Configuration()));
|
|
}
|
|
|
|
[Fact]
|
|
public void BiomeAt_IsConstantWithinACell()
|
|
{
|
|
var (map, _) = Build();
|
|
IBiome a = map.BiomeAt(500f, 500f);
|
|
IBiome b = map.BiomeAt(500.01f, 500.01f); // same cell
|
|
Assert.Same(a, b);
|
|
}
|
|
}
|