Skip to content

Commit

Permalink
Adjust structure chance in LOD.
Browse files Browse the repository at this point in the history
follow-up to 2bc1292
  • Loading branch information
IntegratedQuantum committed Jul 4, 2024
1 parent 212b2f5 commit 117a1d7
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/server/terrain/chunkgen/StructureGenerator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
}
Expand Down

0 comments on commit 117a1d7

Please sign in to comment.