farmesh render range is now dynamic
authorPerttu Ahola <celeron55@gmail.com>
Sat, 18 Jun 2011 10:43:49 +0000 (13:43 +0300)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 18 Jun 2011 10:43:49 +0000 (13:43 +0300)
src/defaultsettings.cpp
src/farmesh.cpp
src/farmesh.h
src/game.cpp

index 209d20b63937e1c0e6c2a5e99bd3bb3e2aa5d662..6eff4ef708b12b21471bda5191194dcde50d15f1 100644 (file)
@@ -49,7 +49,7 @@ void set_default_settings()
        g_settings.setDefault("wanted_fps", "30");
        g_settings.setDefault("fps_max", "60");
        g_settings.setDefault("viewing_range_nodes_max", "300");
-       g_settings.setDefault("viewing_range_nodes_min", "28");
+       g_settings.setDefault("viewing_range_nodes_min", "25");
        g_settings.setDefault("screenW", "800");
        g_settings.setDefault("screenH", "600");
        g_settings.setDefault("address", "");
index efbbeb665bec45c500f79e3d813502c5497686bb..b46d84151833ef653e30616e6019ef3cbb8a44fc 100644 (file)
@@ -50,7 +50,8 @@ FarMesh::FarMesh(
        m_seed(seed),
        m_camera_pos(0,0),
        m_time(0),
-       m_client(client)
+       m_client(client),
+       m_render_range(20*MAP_BLOCKSIZE)
 {
        dstream<<__FUNCTION_NAME<<std::endl;
        
@@ -155,7 +156,7 @@ void FarMesh::render()
        
        //const s16 grid_radius_i = 12;
        //const float grid_size = BS*50;
-       const s16 grid_radius_i = 20;
+       const s16 grid_radius_i = m_render_range/MAP_BLOCKSIZE;
        const float grid_size = BS*MAP_BLOCKSIZE;
        const v2f grid_speed(-BS*0, 0);
        
@@ -354,7 +355,7 @@ void FarMesh::render()
                                video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
 
                // Add some trees if appropriate
-               if(tree_amount_avg >= 0.005 && steepness < 1.0
+               if(tree_amount_avg >= 0.0065 && steepness < 1.4
                                && ground_is_mud == true)
                {
                        driver->setMaterial(m_materials[1]);
@@ -367,11 +368,11 @@ void FarMesh::render()
                                {
                                        video::S3DVertex(p0.X,noise[0],p0.Y,
                                                        0,0,0, c, 0,1),
-                                       video::S3DVertex(p0.X,noise[1]+BS*MAP_BLOCKSIZE,p0.Y,
+                                       video::S3DVertex(p0.X,noise[0]+BS*MAP_BLOCKSIZE,p0.Y,
                                                        0,0,0, c, 0,0),
                                        video::S3DVertex(p1.X,noise[2]+BS*MAP_BLOCKSIZE,p1.Y,
                                                        0,0,0, c, 1,0),
-                                       video::S3DVertex(p1.X,noise[3],p1.Y,
+                                       video::S3DVertex(p1.X,noise[2],p1.Y,
                                                        0,0,0, c, 1,1),
                                };
                                u16 indices[] = {0,1,2,2,3,0};
@@ -382,13 +383,13 @@ void FarMesh::render()
                        {
                                video::S3DVertex vertices[4] =
                                {
-                                       video::S3DVertex(p1.X,noise[0],p0.Y,
+                                       video::S3DVertex(p1.X,noise[3],p0.Y,
                                                        0,0,0, c, 0,1),
-                                       video::S3DVertex(p1.X,noise[1]+BS*MAP_BLOCKSIZE,p0.Y,
+                                       video::S3DVertex(p1.X,noise[3]+BS*MAP_BLOCKSIZE,p0.Y,
                                                        0,0,0, c, 0,0),
-                                       video::S3DVertex(p0.X,noise[2]+BS*MAP_BLOCKSIZE,p1.Y,
+                                       video::S3DVertex(p0.X,noise[1]+BS*MAP_BLOCKSIZE,p1.Y,
                                                        0,0,0, c, 1,0),
-                                       video::S3DVertex(p0.X,noise[3],p1.Y,
+                                       video::S3DVertex(p0.X,noise[1],p1.Y,
                                                        0,0,0, c, 1,1),
                                };
                                u16 indices[] = {0,1,2,2,3,0};
@@ -407,10 +408,11 @@ void FarMesh::step(float dtime)
        m_time += dtime;
 }
 
-void FarMesh::update(v2f camera_p, float brightness)
+void FarMesh::update(v2f camera_p, float brightness, s16 render_range)
 {
        m_camera_pos = camera_p;
        m_brightness = brightness;
+       m_render_range = render_range;
 }
 
 
index aea806542f8706bbc73bb86e0817f9fba1c7c054..0a30a8aefe348a000186f6f2213333c65ab13eb3 100644 (file)
@@ -67,7 +67,7 @@ public:
 
        void step(float dtime);
 
-       void update(v2f camera_p, float brightness);
+       void update(v2f camera_p, float brightness, s16 render_range);
 
 private:
        video::SMaterial m_materials[FARMESH_MATERIAL_COUNT];
@@ -78,6 +78,7 @@ private:
        v2f m_camera_pos;
        float m_time;
        Client *m_client;
+       s16 m_render_range;
 };
 
 #endif
index 237867be179ba2db58a92c6553881331bca8c755..1ab3d7962374f8ce80e3bef5aba4da48fbf3cfc9 100644 (file)
@@ -915,6 +915,7 @@ void the_game(
        core::list<float> frametime_log;
 
        float damage_flash_timer = 0;
+       s16 farmesh_range = 20*MAP_BLOCKSIZE;
        
        bool invert_mouse = g_settings.getBool("invert_mouse");
 
@@ -1826,13 +1827,19 @@ void the_game(
                }
                
                /*
-                       Update farmesh (TODO: Remove from here)
+                       Update farmesh
                */
                if(farmesh)
                {
+                       farmesh_range = draw_control.wanted_range * 10;
+                       if(draw_control.range_all && farmesh_range < 500)
+                               farmesh_range = 500;
+                       if(farmesh_range > 1000)
+                               farmesh_range = 1000;
+
                        farmesh->step(dtime);
                        farmesh->update(v2f(player_position.X, player_position.Z),
-                                       0.05+brightness*0.95);
+                                       0.05+brightness*0.95, farmesh_range);
                }
                
                // Store brightness value
@@ -1847,7 +1854,7 @@ void the_game(
                        f32 range;
                        if(farmesh)
                        {
-                               range = BS*MAP_BLOCKSIZE*20;
+                               range = BS*farmesh_range;
                        }
                        else
                        {
@@ -2054,13 +2061,6 @@ void the_game(
                        beginscenetime = timer.stop(true);
                }
                
-               /*
-                       Draw farmesh before everything else
-               */
-               {
-                       //farmesh->render();
-               }
-
                //timer3.stop();
                
                //std::cout<<DTIME<<"smgr->drawAll()"<<std::endl;