summaryrefslogtreecommitdiff
path: root/src/mapgen.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-29 03:44:37 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-03-29 03:44:37 +0300
commit75821c6889378ff7eba7cddac28acab1537ed934 (patch)
tree09bad70743edb4e81ca19033e1425c811d7f6f0a /src/mapgen.cpp
parentd376148ca1ca05d80936641b22459a3ebbe0a901 (diff)
downloadminetest-75821c6889378ff7eba7cddac28acab1537ed934.tar.gz
minetest-75821c6889378ff7eba7cddac28acab1537ed934.tar.bz2
minetest-75821c6889378ff7eba7cddac28acab1537ed934.zip
Generate beaches
Diffstat (limited to 'src/mapgen.cpp')
-rw-r--r--src/mapgen.cpp19
1 files changed, 11 insertions, 8 deletions
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;