From f501cfd799fb156a32df8791fa3b3ad590d3c0d8 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 14 Dec 2010 13:14:43 +0200 Subject: [PATCH] tinkering around --- makepackage_binary.sh | 4 ++ minetest.vcproj | 4 ++ src/client.cpp | 6 +-- src/client.h | 2 +- src/clientserver.h | 2 +- src/constants.h | 1 + src/main.cpp | 107 +++++++++++++++++------------------------- src/map.cpp | 13 +++++ src/map.h | 12 +---- src/mapblock.cpp | 5 +- src/server.cpp | 2 +- src/tile.cpp | 8 ++++ 12 files changed, 80 insertions(+), 86 deletions(-) diff --git a/makepackage_binary.sh b/makepackage_binary.sh index 1eef35616..ad3ff33d7 100755 --- a/makepackage_binary.sh +++ b/makepackage_binary.sh @@ -40,6 +40,10 @@ cp -r data/torch_on_ceiling.png $PACKAGEPATH/data/ cp -r data/skybox1.png $PACKAGEPATH/data/ cp -r data/skybox2.png $PACKAGEPATH/data/ cp -r data/skybox3.png $PACKAGEPATH/data/ +cp -r data/tree_top.png $PACKAGEPATH/data/ +cp -r data/mud_with_grass.png $PACKAGEPATH/data/ + +cp -r data/pauseMenu.gui $PACKAGEPATH/data/ cp -r doc/README.txt $PACKAGEPATH/doc/README.txt diff --git a/minetest.vcproj b/minetest.vcproj index 774987a7a..632feffff 100644 --- a/minetest.vcproj +++ b/minetest.vcproj @@ -194,6 +194,10 @@ RelativePath=".\src\filesys.cpp" > + + diff --git a/src/client.cpp b/src/client.cpp index bfec8b730..ed3a43759 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1401,11 +1401,11 @@ void Client::addNodeFromInventory(v3s16 nodepos, u16 i) } #endif -void Client::clickGround(u8 button, v3s16 nodepos_undersurface, +void Client::pressGround(u8 button, v3s16 nodepos_undersurface, v3s16 nodepos_oversurface, u16 item) { if(connectedAndInitialized() == false){ - dout_client< data(datasize); - writeU16(&data[0], TOSERVER_CLICK_GROUND); + writeU16(&data[0], TOSERVER_PRESS_GROUND); writeU8(&data[2], button); writeV3S16(&data[3], nodepos_undersurface); writeV3S16(&data[9], nodepos_oversurface); diff --git a/src/client.h b/src/client.h index 3789f4cbe..95bff0ff5 100644 --- a/src/client.h +++ b/src/client.h @@ -193,7 +193,7 @@ public: /*void removeNode(v3s16 nodepos); void addNodeFromInventory(v3s16 nodepos, u16 i);*/ - void clickGround(u8 button, v3s16 nodepos_undersurface, + void pressGround(u8 button, v3s16 nodepos_undersurface, v3s16 nodepos_oversurface, u16 item); void clickObject(u8 button, v3s16 blockpos, s16 id, u16 item); void release(u8 button); diff --git a/src/clientserver.h b/src/clientserver.h index ce595b6d4..9d3545907 100644 --- a/src/clientserver.h +++ b/src/clientserver.h @@ -159,7 +159,7 @@ enum ToServerCommand [11] u16 item */ - TOSERVER_CLICK_GROUND = 0x28, + TOSERVER_PRESS_GROUND = 0x28, /* length: 17 [0] u16 command diff --git a/src/constants.h b/src/constants.h index bbd9fa823..83a070217 100644 --- a/src/constants.h +++ b/src/constants.h @@ -45,6 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define SERVER_MAP_SAVE_INTERVAL (10)*/ #define FOV_ANGLE (PI/2.5) +//#define FOV_ANGLE (PI/2.25) // The absolute working limit is (2^15 - viewing_range). #define MAP_GENERATION_LIMIT (31000) diff --git a/src/main.cpp b/src/main.cpp index 31901ae70..7814da999 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -280,6 +280,7 @@ JMutex g_range_mutex; // Blocks are viewed in this range from the player s16 g_viewing_range_nodes = 60; +//s16 g_viewing_range_nodes = 0; // This is updated by the client's fetchBlocks routine //s16 g_actual_viewing_range_nodes = VIEWING_RANGE_NODES_DEFAULT; @@ -311,7 +312,7 @@ void set_default_settings() g_settings.set("wanted_fps", "30"); g_settings.set("fps_max", "60"); g_settings.set("viewing_range_nodes_max", "300"); - g_settings.set("viewing_range_nodes_min", "50"); + g_settings.set("viewing_range_nodes_min", "35"); g_settings.set("screenW", ""); g_settings.set("screenH", ""); g_settings.set("host_game", ""); @@ -796,7 +797,8 @@ void updateViewingRange(f32 frametime, Client *client) static bool fraction_is_good = false; float fraction_good_threshold = 0.1; - float fraction_bad_threshold = 0.25; + //float fraction_bad_threshold = 0.25; + float fraction_bad_threshold = 0.1; float fraction_limit; // Use high limit if fraction is good AND the fraction would // lower the range. We want to keep the range fairly high. @@ -1294,48 +1296,6 @@ int main(int argc, char *argv[]) guienv->drawAll(); driver->endScene(); - /* - Initialize material array - */ - - /*//video::SMaterial g_materials[MATERIALS_COUNT]; - for(u16 i=0; igetTexture(filename); - if(t == NULL){ - std::cout<getTexture(filename)); - } - //g_materials[i].setFlag(video::EMF_TEXTURE_WRAP, video::ETC_REPEAT); - g_materials[i].setFlag(video::EMF_BILINEAR_FILTER, false); - //g_materials[i].setFlag(video::EMF_ANISOTROPIC_FILTER, false); - //g_materials[i].setFlag(video::EMF_FOG_ENABLE, true); - } - - g_materials[CONTENT_WATER].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - //g_materials[CONTENT_WATER].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; - g_materials[CONTENT_OCEAN].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; - */ - - /*g_mesh_materials[0].setTexture(0, driver->getTexture("../data/water.png")); - g_mesh_materials[1].setTexture(0, driver->getTexture("../data/grass.png")); - g_mesh_materials[2].setTexture(0, driver->getTexture("../data/stone.png")); - for(u32 i=0; i<3; i++) - { - g_mesh_materials[i].Lighting = false; - g_mesh_materials[i].BackfaceCulling = false; - g_mesh_materials[i].setFlag(video::EMF_BILINEAR_FILTER, false); - g_mesh_materials[i].setFlag(video::EMF_FOG_ENABLE, true); - }*/ - /* Preload some random textures that are used in threads */ @@ -1463,9 +1423,15 @@ int main(int argc, char *argv[]) f32 camera_yaw = 0; // "right/left" f32 camera_pitch = 0; // "up/down" + + /* + Move into game + */ gui_loadingtext->remove(); + pauseMenu.setVisible(true); + /* Add some gui stuff */ @@ -1473,12 +1439,12 @@ int main(int argc, char *argv[]) // First line of debug text gui::IGUIStaticText *guitext = guienv->addStaticText( L"Minetest-c55", - core::rect(5, 5, 5+600, 5+textsize.Y), + core::rect(5, 5, 795, 5+textsize.Y), false, false); // Second line of debug text gui::IGUIStaticText *guitext2 = guienv->addStaticText( L"", - core::rect(5, 5+(textsize.Y+5)*1, 5+600, (5+textsize.Y)*2), + core::rect(5, 5+(textsize.Y+5)*1, 795, (5+textsize.Y)*2), false, false); // At the middle of the screen @@ -1498,6 +1464,7 @@ int main(int argc, char *argv[]) Some statistics are collected in these */ u32 drawtime = 0; + u32 beginscenetime = 0; u32 scenetime = 0; u32 endscenetime = 0; @@ -2063,14 +2030,14 @@ int main(int argc, char *argv[]) //std::cout<getRightClicked()) { //std::cout<setAspectRatio((f32)screensize.X / (f32)screensize.Y); + /*f32 range = g_viewing_range_nodes * BS; + if(g_viewing_range_all) + range = 100000*BS; + + driver->setFog( + skycolor, + video::EFT_FOG_LINEAR, + range*0.6, + range, + 0.01, + false, // pixel fog + false // range fog + );*/ + + /* Update gui stuff (0ms) */ @@ -2096,23 +2078,26 @@ int main(int argc, char *argv[]) //TimeTaker guiupdatetimer("Gui updating", device); { - wchar_t temptext[100]; + wchar_t temptext[150]; static float drawtime_avg = 0; drawtime_avg = drawtime_avg * 0.98 + (float)drawtime*0.02; + static float beginscenetime_avg = 0; + beginscenetime_avg = beginscenetime_avg * 0.98 + (float)beginscenetime*0.02; static float scenetime_avg = 0; scenetime_avg = scenetime_avg * 0.98 + (float)scenetime*0.02; static float endscenetime_avg = 0; endscenetime_avg = endscenetime_avg * 0.98 + (float)endscenetime*0.02; - swprintf(temptext, 100, L"Minetest-c55 (" + swprintf(temptext, 150, L"Minetest-c55 (" L"F: item=%i" L", R: range_all=%i" L")" - L" drawtime=%.0f, scenetime=%.0f, endscenetime=%.0f", + L" drawtime=%.0f, beginscenetime=%.0f, scenetime=%.0f, endscenetime=%.0f", g_selected_item, g_viewing_range_all, drawtime_avg, + beginscenetime_avg, scenetime_avg, endscenetime_avg ); @@ -2121,19 +2106,8 @@ int main(int argc, char *argv[]) } { - wchar_t temptext[100]; - /*swprintf(temptext, 100, - L"(" - L"% .3f < btime_jitter < % .3f" - L", dtime_jitter = % .1f %%" - //L", ftime_ratio = % .3f" - L")", - busytime_jitter1_min_sample, - busytime_jitter1_max_sample, - dtime_jitter1_max_fraction * 100.0 - //g_freetime_ratio - );*/ - swprintf(temptext, 100, + wchar_t temptext[150]; + swprintf(temptext, 150, L"(% .1f, % .1f, % .1f)" L" (% .3f < btime_jitter < % .3f" L", dtime_jitter = % .1f %%)", @@ -2232,8 +2206,11 @@ int main(int argc, char *argv[]) //video::SColor bgcolor = video::SColor(255,90,140,200); video::SColor bgcolor = skycolor; - // 0ms + { + TimeTaker timer("beginScene", device); driver->beginScene(true, true, bgcolor); + beginscenetime = timer.stop(true); + } //timer3.stop(); diff --git a/src/map.cpp b/src/map.cpp index b1e7da29a..caebb5161 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -2835,6 +2835,17 @@ void ClientMap::deSerializeSector(v2s16 p2d, std::istream &is) sector->deSerialize(is); } +void ClientMap::OnRegisterSceneNode() +{ + if(IsVisible) + { + SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); + SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); + } + + ISceneNode::OnRegisterSceneNode(); +} + void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass) { //m_dout< viewing_range_nodes * BS) + // This is nicer when fog is used + //if((dforward+d)/2 > viewing_range_nodes * BS) continue; } diff --git a/src/map.h b/src/map.h index d36e2ddad..9ab77b25f 100644 --- a/src/map.h +++ b/src/map.h @@ -545,17 +545,7 @@ public: ISceneNode methods */ - virtual void OnRegisterSceneNode() - { - if(IsVisible) - { - //SceneManager->registerNodeForRendering(this, scene::ESNRP_SKY_BOX); - SceneManager->registerNodeForRendering(this, scene::ESNRP_SOLID); - SceneManager->registerNodeForRendering(this, scene::ESNRP_TRANSPARENT); - } - - ISceneNode::OnRegisterSceneNode(); - } + virtual void OnRegisterSceneNode(); virtual void render() { diff --git a/src/mapblock.cpp b/src/mapblock.cpp index e2e36c8e3..86bd9c98c 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -118,9 +118,6 @@ FastFace * MapBlock::makeFastFace(u16 tile, u8 light, v3f p, u8 alpha = 255; - //if(material == CONTENT_WATER || material == CONTENT_OCEAN) - //TODO: Umm? - //if(tile == CONTENT_WATER || tile == CONTENT_OCEAN) if(tile == TILE_WATER) { alpha = 128; @@ -139,7 +136,7 @@ FastFace * MapBlock::makeFastFace(u16 tile, u8 light, v3f p, f->tile = tile; //DEBUG - //f->tile = TILE_GRASS; + //f->tile = TILE_STONE; return f; } diff --git a/src/server.cpp b/src/server.cpp index 487ce2a98..88a8492c1 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -1466,7 +1466,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) block->removeObject(id); } } - else if(command == TOSERVER_CLICK_GROUND) + else if(command == TOSERVER_PRESS_GROUND) { if(datasize < 17) return; diff --git a/src/tile.cpp b/src/tile.cpp index 580d2a8a3..32db69672 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -53,9 +53,17 @@ void tile_materials_preload(TextureCache &cache) g_tile_materials[i].Lighting = false; g_tile_materials[i].BackfaceCulling = false; g_tile_materials[i].setFlag(video::EMF_BILINEAR_FILTER, false); + g_tile_materials[i].setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF); + //if(i != TILE_WATER) + //g_tile_materials[i].setFlag(video::EMF_FOG_ENABLE, true); + + //g_tile_materials[i].setFlag(video::EMF_TEXTURE_WRAP, video::ETC_REPEAT); + //g_tile_materials[i].setFlag(video::EMF_ANISOTROPIC_FILTER, false); + g_tile_materials[i].setTexture(0, t); } g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; + //g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; } -- 2.25.1