Generate beaches
authorPerttu Ahola <celeron55@gmail.com>
Thu, 29 Mar 2012 00:44:37 +0000 (03:44 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Thu, 29 Mar 2012 00:44:37 +0000 (03:44 +0300)
src/farmesh.cpp
src/mapgen.cpp
src/mapgen.h

index 836d9bd8731793d9a039d4c3bba958d42edadf5c..2b36feb4a03e453fec3050278c53c7a619bee5e6 100644 (file)
@@ -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
index ceef9c61085bf4f021493ce1e0f32cc4aea19909..3212b693289921012b1be52d3b7c7d920ecdf404 100644 (file)
@@ -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;
index 3374c678212d893d0a849c22ed8a78427e77af30..1a29d90d938d724689fc1549a15560ffe0d0bfd5 100644 (file)
@@ -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