From e15dca2a9fac70dd4f541f7b37c6f61fcf974ea1 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 27 Jan 2012 04:16:44 +0200 Subject: [PATCH] Fix tree generation density for different mapgen chunk sizes --- src/mapgen.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 0b8781f5..6fecbb45 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1519,11 +1519,16 @@ void make_block(BlockMakeData *data) // Full allocated area v3s16 full_node_min = (blockpos_min-1)*MAP_BLOCKSIZE; v3s16 full_node_max = (blockpos_max+2)*MAP_BLOCKSIZE-v3s16(1,1,1); - // Area of a block - double block_area_nodes = MAP_BLOCKSIZE*MAP_BLOCKSIZE; v2s16 p2d_center(node_min.X+MAP_BLOCKSIZE/2, node_min.Z+MAP_BLOCKSIZE/2); + int rel_volume = (blockpos_max.X - blockpos_min.X + 1) + * (blockpos_max.Y - blockpos_min.Y + 1) + * (blockpos_max.Z - blockpos_max.Z + 1); + + // Area of the block we are generating + double gen_area_nodes = MAP_BLOCKSIZE*MAP_BLOCKSIZE * rel_volume; + /* Get average ground level from noise */ @@ -1998,7 +2003,7 @@ void make_block(BlockMakeData *data) float surface_humidity = surface_humidity_2d(data->seed, p2d_center); bool is_jungle = surface_humidity > 0.75; // Amount of trees - u32 tree_count = block_area_nodes * tree_amount_2d(data->seed, p2d_center); + u32 tree_count = gen_area_nodes * tree_amount_2d(data->seed, p2d_center); if(is_jungle) tree_count *= 5; @@ -2132,7 +2137,7 @@ void make_block(BlockMakeData *data) Add some kind of random stones */ - u32 random_stone_count = block_area_nodes * + u32 random_stone_count = gen_area_nodes * randomstone_amount_2d(data->seed, p2d_center); // Put in random places on part of division for(u32 i=0; iseed, p2d_center); //u32 large_stone_count = 1; // Put in random places on part of division -- 2.30.2