From 117a1d7f7147a3831ec84f3209eac63596c7de01 Mon Sep 17 00:00:00 2001 From: IntegratedQuantum Date: Thu, 4 Jul 2024 11:27:32 +0200 Subject: [PATCH] Adjust structure chance in LOD. follow-up to 2bc1292fc3ec50168dedfae94f01e2fcf3adc8e9 --- src/server/terrain/chunkgen/StructureGenerator.zig | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/server/terrain/chunkgen/StructureGenerator.zig b/src/server/terrain/chunkgen/StructureGenerator.zig index 84a5d49ca..4f70034d4 100644 --- a/src/server/terrain/chunkgen/StructureGenerator.zig +++ b/src/server/terrain/chunkgen/StructureGenerator.zig @@ -56,7 +56,6 @@ pub fn generate(worldSeed: u64, chunk: *main.chunk.ServerChunk, caveMap: CaveMap model.generate(px, py, relZ, chunk, caveMap, &seed); break; } else { - // Make sure that after the first one was considered all others get the correct chances. randomValue -= model.chance; } } @@ -77,15 +76,14 @@ pub fn generate(worldSeed: u64, chunk: *main.chunk.ServerChunk, caveMap: CaveMap var randomValue = random.nextFloat(&seed); const biome = biomeMap.getBiome(px, py, relZ); for(biome.vegetationModels) |model| { // TODO: Could probably use an alias table here. - var adaptedChance = model.chance; + var adaptedChance = model.chance/16; // Increase chance if there are less spawn points considered. Messes up positions, but at that distance density matters more. adaptedChance = 1 - std.math.pow(f32, 1 - adaptedChance, @as(f32, @floatFromInt(chunk.super.pos.voxelSize*chunk.super.pos.voxelSize))); if(randomValue < adaptedChance) { model.generate(px - 16, py - 16, relZ, chunk, caveMap, &seed); break; } else { - // Make sure that after the first one was considered all others get the correct chances. - randomValue = (randomValue - adaptedChance)/(1 - adaptedChance); + randomValue -= adaptedChance; } } }