1
0
mirror of https://github.com/moparisthebest/minetest synced 2024-12-23 16:08:51 -05:00

farmesh render range is now dynamic

This commit is contained in:
Perttu Ahola 2011-06-18 13:43:49 +03:00
parent 7d0395ba36
commit c78d610618
4 changed files with 25 additions and 22 deletions

View File

@ -49,7 +49,7 @@ void set_default_settings()
g_settings.setDefault("wanted_fps", "30"); g_settings.setDefault("wanted_fps", "30");
g_settings.setDefault("fps_max", "60"); g_settings.setDefault("fps_max", "60");
g_settings.setDefault("viewing_range_nodes_max", "300"); 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("screenW", "800");
g_settings.setDefault("screenH", "600"); g_settings.setDefault("screenH", "600");
g_settings.setDefault("address", ""); g_settings.setDefault("address", "");

View File

@ -50,7 +50,8 @@ FarMesh::FarMesh(
m_seed(seed), m_seed(seed),
m_camera_pos(0,0), m_camera_pos(0,0),
m_time(0), m_time(0),
m_client(client) m_client(client),
m_render_range(20*MAP_BLOCKSIZE)
{ {
dstream<<__FUNCTION_NAME<<std::endl; dstream<<__FUNCTION_NAME<<std::endl;
@ -155,7 +156,7 @@ void FarMesh::render()
//const s16 grid_radius_i = 12; //const s16 grid_radius_i = 12;
//const float grid_size = BS*50; //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 float grid_size = BS*MAP_BLOCKSIZE;
const v2f grid_speed(-BS*0, 0); const v2f grid_speed(-BS*0, 0);
@ -354,7 +355,7 @@ void FarMesh::render()
video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT); video::EVT_STANDARD, scene::EPT_TRIANGLES, video::EIT_16BIT);
// Add some trees if appropriate // 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) && ground_is_mud == true)
{ {
driver->setMaterial(m_materials[1]); driver->setMaterial(m_materials[1]);
@ -367,11 +368,11 @@ void FarMesh::render()
{ {
video::S3DVertex(p0.X,noise[0],p0.Y, video::S3DVertex(p0.X,noise[0],p0.Y,
0,0,0, c, 0,1), 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), 0,0,0, c, 0,0),
video::S3DVertex(p1.X,noise[2]+BS*MAP_BLOCKSIZE,p1.Y, video::S3DVertex(p1.X,noise[2]+BS*MAP_BLOCKSIZE,p1.Y,
0,0,0, c, 1,0), 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), 0,0,0, c, 1,1),
}; };
u16 indices[] = {0,1,2,2,3,0}; u16 indices[] = {0,1,2,2,3,0};
@ -382,13 +383,13 @@ void FarMesh::render()
{ {
video::S3DVertex vertices[4] = 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), 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), 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), 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), 0,0,0, c, 1,1),
}; };
u16 indices[] = {0,1,2,2,3,0}; u16 indices[] = {0,1,2,2,3,0};
@ -407,10 +408,11 @@ void FarMesh::step(float dtime)
m_time += 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_camera_pos = camera_p;
m_brightness = brightness; m_brightness = brightness;
m_render_range = render_range;
} }

View File

@ -67,7 +67,7 @@ public:
void step(float dtime); void step(float dtime);
void update(v2f camera_p, float brightness); void update(v2f camera_p, float brightness, s16 render_range);
private: private:
video::SMaterial m_materials[FARMESH_MATERIAL_COUNT]; video::SMaterial m_materials[FARMESH_MATERIAL_COUNT];
@ -78,6 +78,7 @@ private:
v2f m_camera_pos; v2f m_camera_pos;
float m_time; float m_time;
Client *m_client; Client *m_client;
s16 m_render_range;
}; };
#endif #endif

View File

@ -915,6 +915,7 @@ void the_game(
core::list<float> frametime_log; core::list<float> frametime_log;
float damage_flash_timer = 0; float damage_flash_timer = 0;
s16 farmesh_range = 20*MAP_BLOCKSIZE;
bool invert_mouse = g_settings.getBool("invert_mouse"); 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) 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->step(dtime);
farmesh->update(v2f(player_position.X, player_position.Z), farmesh->update(v2f(player_position.X, player_position.Z),
0.05+brightness*0.95); 0.05+brightness*0.95, farmesh_range);
} }
// Store brightness value // Store brightness value
@ -1847,7 +1854,7 @@ void the_game(
f32 range; f32 range;
if(farmesh) if(farmesh)
{ {
range = BS*MAP_BLOCKSIZE*20; range = BS*farmesh_range;
} }
else else
{ {
@ -2054,13 +2061,6 @@ void the_game(
beginscenetime = timer.stop(true); beginscenetime = timer.stop(true);
} }
/*
Draw farmesh before everything else
*/
{
//farmesh->render();
}
//timer3.stop(); //timer3.stop();
//std::cout<<DTIME<<"smgr->drawAll()"<<std::endl; //std::cout<<DTIME<<"smgr->drawAll()"<<std::endl;