From: Perttu Ahola Date: Fri, 27 Jan 2012 02:16:44 +0000 (+0200) Subject: Fix tree generation density for different mapgen chunk sizes X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=e15dca2a9fac70dd4f541f7b37c6f61fcf974ea1;p=zefram%2Fminetest%2Fminetest_engine.git Fix tree generation density for different mapgen chunk sizes --- 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