From c78d61061863559cc3daf6b838a0f936ce53acf9 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sat, 18 Jun 2011 13:43:49 +0300 Subject: [PATCH] farmesh render range is now dynamic --- src/defaultsettings.cpp | 2 +- src/farmesh.cpp | 22 ++++++++++++---------- src/farmesh.h | 3 ++- src/game.cpp | 20 ++++++++++---------- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 209d20b6..6eff4ef7 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -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", ""); diff --git a/src/farmesh.cpp b/src/farmesh.cpp index efbbeb66..b46d8415 100644 --- a/src/farmesh.cpp +++ b/src/farmesh.cpp @@ -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<= 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; } diff --git a/src/farmesh.h b/src/farmesh.h index aea80654..0a30a8ae 100644 --- a/src/farmesh.h +++ b/src/farmesh.h @@ -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 diff --git a/src/game.cpp b/src/game.cpp index 237867be..1ab3d796 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -915,6 +915,7 @@ void the_game( core::list 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<drawAll()"<