diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-03-29 03:44:37 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-03-29 03:44:37 +0300 |
commit | 75821c6889378ff7eba7cddac28acab1537ed934 (patch) | |
tree | 09bad70743edb4e81ca19033e1425c811d7f6f0a | |
parent | d376148ca1ca05d80936641b22459a3ebbe0a901 (diff) | |
download | minetest-75821c6889378ff7eba7cddac28acab1537ed934.tar.gz minetest-75821c6889378ff7eba7cddac28acab1537ed934.tar.bz2 minetest-75821c6889378ff7eba7cddac28acab1537ed934.zip |
Generate beaches
-rw-r--r-- | src/farmesh.cpp | 2 | ||||
-rw-r--r-- | src/mapgen.cpp | 19 | ||||
-rw-r--r-- | src/mapgen.h | 2 |
3 files changed, 13 insertions, 10 deletions
diff --git a/src/farmesh.cpp b/src/farmesh.cpp index 836d9bd87..2b36feb4a 100644 --- a/src/farmesh.cpp +++ b/src/farmesh.cpp @@ -125,7 +125,7 @@ HeightPoint ground_height(u64 seed, v2s16 p2d) hp.ma = (4)*BS; /*hp.gh = BS*base_rock_level_2d(seed, p2d); hp.ma = BS*get_mud_add_amount(seed, p2d);*/ - hp.have_sand = mapgen::get_have_sand(seed, p2d); + hp.have_sand = mapgen::get_have_beach(seed, p2d); if(hp.gh > BS*WATER_LEVEL) hp.tree_amount = mapgen::tree_amount_2d(seed, p2d); else diff --git a/src/mapgen.cpp b/src/mapgen.cpp index ceef9c610..3212b6932 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1268,14 +1268,14 @@ double get_mud_add_amount(u64 seed, v2s16 p) seed+91013, 3, 0.55)); } -bool get_have_sand(u64 seed, v2s16 p2d) +bool get_have_beach(u64 seed, v2s16 p2d) { // Determine whether to have sand here double sandnoise = noise2d_perlin( 0.5+(float)p2d.X/500, 0.5+(float)p2d.Y/500, seed+59420, 3, 0.50); - return (sandnoise > -0.15); + return (sandnoise > 0.15); } u32 get_blockseed(u64 seed, v3s16 p) @@ -1769,17 +1769,20 @@ void make_block(BlockMakeData *data) // Randomize mud amount s16 mud_add_amount = get_mud_add_amount(data->seed, p2d) / 2.0; - if(mud_add_amount <= 0){ - mud_add_amount = 1 - mud_add_amount; - addnode = MapNode(c_gravel); - } - // Find ground level s16 surface_y = find_stone_level(vmanip, p2d, ndef); // Handle area not found if(surface_y == vmanip.m_area.MinEdge.Y - 1) continue; + if(mud_add_amount <= 0){ + mud_add_amount = 1 - mud_add_amount; + addnode = MapNode(c_gravel); + } else if(get_have_beach(data->seed, p2d) && + surface_y + mud_add_amount <= WATER_LEVEL+2){ + addnode = MapNode(c_sand); + } + /* If topmost node is grass, change it to mud. It might be if it was flown to there from a neighboring @@ -2367,7 +2370,7 @@ void make_block(BlockMakeData *data) // Node position v2s16 p2d(x,z); { - bool possibly_have_sand = get_have_sand(data->seed, p2d); + bool possibly_have_sand = get_have_beach(data->seed, p2d); bool have_sand = false; u32 current_depth = 0; bool air_detected = false; diff --git a/src/mapgen.h b/src/mapgen.h index 3374c6782..1a29d90d9 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -49,7 +49,7 @@ namespace mapgen /* These are used by FarMesh */ - bool get_have_sand(u64 seed, v2s16 p2d); + bool get_have_beach(u64 seed, v2s16 p2d); double tree_amount_2d(u64 seed, v2s16 p); struct BlockMakeData |