]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/farmesh.cpp
Merge branch 'upstream/master'
[dragonfireclient.git] / src / farmesh.cpp
index b46d84151833ef653e30616e6019ef3cbb8a44fc..2cd92243425c7d3c8a11212ac4288d882d291127 100644 (file)
@@ -29,15 +29,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "map.h"
 #include "client.h"
 
-/*
-       Temporarily exposed map generator stuff
-       Should only be used for testing
-*/
-extern double base_rock_level_2d(u64 seed, v2s16 p);
-extern double get_mud_add_amount(u64 seed, v2s16 p);
-extern bool get_have_sand(u64 seed, v2s16 p2d);
-extern double tree_amount_2d(u64 seed, v2s16 p);
-
+#include "mapgen.h"
 
 FarMesh::FarMesh(
                scene::ISceneNode* parent,
@@ -78,6 +70,7 @@ FarMesh::FarMesh(
        m_box = core::aabbox3d<f32>(-BS*1000000,-BS*31000,-BS*1000000,
                        BS*1000000,BS*31000,BS*1000000);
 
+    trees = g_settings.getBool("farmesh_trees");
 }
 
 FarMesh::~FarMesh()
@@ -126,17 +119,20 @@ HeightPoint ground_height(u64 seed, v2s16 p2d)
        if(n)
                return n->getValue();
        HeightPoint hp;
-       hp.gh = BS*base_rock_level_2d(seed, p2d);
-       hp.ma = BS*get_mud_add_amount(seed, p2d);
-       hp.have_sand = get_have_sand(seed, p2d);
+       s16 level = mapgen::find_ground_level_from_noise(seed, p2d, 3);
+       hp.gh = (level-4)*BS;
+       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);
        if(hp.gh > BS*WATER_LEVEL)
-               hp.tree_amount = tree_amount_2d(seed, p2d);
+               hp.tree_amount = mapgen::tree_amount_2d(seed, p2d);
        else
                hp.tree_amount = 0;
        // No mud has been added if mud amount is less than 1
        if(hp.ma < 1.0*BS)
                hp.ma = 0.0;
-       hp.gh -= BS*3; // Lower a bit so that it is not that much in the way
+       //hp.gh -= BS*3; // Lower a bit so that it is not that much in the way
        g_heights[p2d] = hp;
        return hp;
 }
@@ -284,7 +280,8 @@ void FarMesh::render()
                if(h_avg < WATER_LEVEL*BS && h_max < (WATER_LEVEL+5)*BS)
                {
                        //c = video::SColor(255,59,86,146);
-                       c = video::SColor(255,82,120,204);
+                       //c = video::SColor(255,82,120,204);
+                       c = video::SColor(255,74,105,170);
 
                        /*// Set to water level
                        for(u32 i=0; i<4; i++)
@@ -317,12 +314,11 @@ void FarMesh::render()
                                }
                                else
                                {
-                                       /*// Trees if there are over 0.01 trees per MapNode
-                                       if(tree_amount_avg > 0.01)
+                                       // Trees if there are over 0.01 trees per MapNode
+                                       if(trees && tree_amount_avg > 0.01)
                                                c = video::SColor(255,50,128,50);
                                        else
-                                               c = video::SColor(255,107,134,51);*/
-                                       c = video::SColor(255,107,134,51);
+                                               c = video::SColor(255,107,134,51);
                                        ground_is_mud = true;
                                }
                        }
@@ -355,7 +351,7 @@ void FarMesh::render()
                                video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
 
                // Add some trees if appropriate
-               if(tree_amount_avg >= 0.0065 && steepness < 1.4
+               if(trees && tree_amount_avg >= 0.0065 && steepness < 1.4
                                && ground_is_mud == true)
                {
                        driver->setMaterial(m_materials[1]);
@@ -408,11 +404,11 @@ void FarMesh::step(float dtime)
        m_time += dtime;
 }
 
-void FarMesh::update(v2f camera_p, float brightness, s16 render_range)
+void FarMesh::update(v2f camera_p, float brightness)
 {
        m_camera_pos = camera_p;
        m_brightness = brightness;
-       m_render_range = render_range;
+       m_render_range = g_settings.getS16("farmesh_distance")*10;
 }