From: Perttu Ahola Date: Fri, 6 May 2011 13:58:06 +0000 (+0300) Subject: Fixed viewing range stuff a bit (now it works better with very low ranges) X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=1a6e1e142f70d0be7ed1a867801fe130bede7802;p=zefram%2Fminetest%2Fminetest_engine.git Fixed viewing range stuff a bit (now it works better with very low ranges) --- diff --git a/src/game.cpp b/src/game.cpp index 92e690a2..f32a2f0c 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -181,8 +181,15 @@ void updateViewingRange(f32 frametime_in, Client *client) float range_min = g_settings.getS16("viewing_range_nodes_min"); float range_max = g_settings.getS16("viewing_range_nodes_max"); + // Limit minimum to keep the feedback loop stable + if(range_min < 5) + range_min = 5; + draw_control.wanted_min_range = range_min; - draw_control.wanted_max_blocks = (1.2*draw_control.blocks_drawn)+1; + //draw_control.wanted_max_blocks = (1.5*draw_control.blocks_drawn)+1; + draw_control.wanted_max_blocks = (1.5*draw_control.blocks_would_have_drawn)+1; + if(draw_control.wanted_max_blocks < 10) + draw_control.wanted_max_blocks = 10; float block_draw_ratio = 1.0; if(draw_control.blocks_would_have_drawn != 0) @@ -261,18 +268,15 @@ void updateViewingRange(f32 frametime_in, Client *client) } new_range += wanted_range_change; - //dstream<<"new_range="< range_max) new_range = range_max; - /*if(new_range != new_range_unclamped) - dstream<<", clamped to "<getDimension(text).Height; + const wchar_t *loadingtext = L"Loading and connecting..."; + u32 text_height = font->getDimension(loadingtext).Height; core::vector2d center(screensize.X/2, screensize.Y/2); core::vector2d textsize(300, text_height); core::rect textrect(center - textsize/2, center + textsize/2); gui::IGUIStaticText *gui_loadingtext = guienv->addStaticText( - text, textrect, false, false); + loadingtext, textrect, false, false); gui_loadingtext->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); driver->beginScene(true, true, video::SColor(255,0,0,0)); @@ -793,9 +797,8 @@ void the_game( */ float cloud_height = BS*100; - //float cloud_height = BS*55; - //float cloud_height = BS*20; - Clouds *clouds = new Clouds(smgr->getRootSceneNode(), smgr, -1, + Clouds *clouds = NULL; + clouds = new Clouds(smgr->getRootSceneNode(), smgr, -1, cloud_height, time(0)); /* @@ -1729,9 +1732,12 @@ void the_game( /* Update coulds */ - clouds->step(dtime); - clouds->update(v2f(player_position.X, player_position.Z), - 0.05+brightness*0.95); + if(clouds) + { + clouds->step(dtime); + clouds->update(v2f(player_position.X, player_position.Z), + 0.05+brightness*0.95); + } // Store brightness value old_brightness = brightness; @@ -1745,6 +1751,8 @@ void the_game( f32 range = draw_control.wanted_range*BS + MAP_BLOCKSIZE*BS*1.5; if(draw_control.range_all) range = 100000*BS; + if(range < 50*BS) + range = range * 0.5 + 25*BS; driver->setFog( bgcolor, @@ -2069,6 +2077,22 @@ void the_game( lastFPS = fps; } } + + /* + Draw a "shutting down" screen, which will be shown while the map + generator and other stuff quits + */ + { + const wchar_t *shuttingdowntext = L"Shutting down stuff..."; + gui::IGUIStaticText *gui_shuttingdowntext = guienv->addStaticText( + shuttingdowntext, textrect, false, false); + gui_shuttingdowntext->setTextAlignment(gui::EGUIA_CENTER, + gui::EGUIA_UPPERLEFT); + driver->beginScene(true, true, video::SColor(255,0,0,0)); + guienv->drawAll(); + driver->endScene(); + gui_shuttingdowntext->remove(); + } } diff --git a/src/utility.cpp b/src/utility.cpp index 95c5d8bf..fc657b27 100644 --- a/src/utility.cpp +++ b/src/utility.cpp @@ -184,6 +184,10 @@ bool isBlockInSight(v3s16 blockpos_b, v3f camera_pos, v3f camera_dir, f32 range, if(distance_ptr) *distance_ptr = d; + // If block is very close, it is always in sight + if(d < 1.44*1.44*MAP_BLOCKSIZE*BS/2) + return true; + // If block is far away, it's not in sight if(d > range * BS) return false;