From 4c2b9ed516e3109d5c74a37c9479a516beae4f50 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Fri, 18 Feb 2011 22:25:25 +0200 Subject: [PATCH] random code cleaning, shouldn't affect anything --- src/light.cpp | 21 ++++++++++++++ src/main.cpp | 25 ++++++++++++---- src/mapblock.cpp | 27 ++++-------------- src/server.cpp | 74 ++++++------------------------------------------ 4 files changed, 56 insertions(+), 91 deletions(-) diff --git a/src/light.cpp b/src/light.cpp index 1e4dfcdf..5dade2e1 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -19,7 +19,28 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "light.h" +// This is reasonable with classic lighting with a light source +/*u8 light_decode_table[LIGHT_MAX+1] = +{ +2, +3, +4, +6, +9, +13, +18, +25, +32, +35, +45, +57, +69, +79, +255 +};*/ + +// This is good // a_n+1 = a_n * 0.786 // Length of LIGHT_MAX+1 means LIGHT_MAX is the last value. // LIGHT_SUN is read as LIGHT_MAX from here. diff --git a/src/main.cpp b/src/main.cpp index b0fe5932..11ae9985 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -277,15 +277,13 @@ Doing now (most important at the top): placement and transfer * only_from_disk might not work anymore - check and fix it. * Check the fixmes in the list above -* When sending blocks to the client, the server takes way too much - CPU time (20-30% for single player), find out what it is doing. - - Make a simple profiler === Making it more portable * Some MSVC: std::sto* are defined without a namespace and collide with the ones in utility.h === Features +* Add mud underground * Make an "environment metafile" to store at least time of day * Move digging property stuff from material.{h,cpp} to mapnode.cpp... - Or maybe move content_features to material.{h,cpp}? @@ -1794,7 +1792,7 @@ int main(int argc, char *argv[]) //driver->setMinHardwareBufferVertexCount(50); scene::ISceneManager* smgr = device->getSceneManager(); - + guienv = device->getGUIEnvironment(); gui::IGUISkin* skin = guienv->getSkin(); gui::IGUIFont* font = guienv->getFont(porting::getDataPath("fontlucida.png").c_str()); @@ -2104,7 +2102,7 @@ int main(int argc, char *argv[]) if(camera == NULL) return 1; - + //video::SColor skycolor = video::SColor(255,90,140,200); //video::SColor skycolor = video::SColor(255,166,202,244); video::SColor skycolor = video::SColor(255,120,185,244); @@ -2113,6 +2111,23 @@ int main(int argc, char *argv[]) // Just so big a value that everything rendered is visible camera->setFarValue(100000*BS); + + /* + Lighting test code. Doesn't quite work this way. + The CPU-computed lighting is good. + */ + + /* + smgr->addLightSceneNode(NULL, + v3f(0, BS*1000000, 0), + video::SColorf(0.3,0.3,0.3), + BS*10000000); + + smgr->setAmbientLight(video::SColorf(0.0, 0.0, 0.0)); + + scene::ILightSceneNode *light = smgr->addLightSceneNode(camera, + v3f(0, 0, 0), video::SColorf(0.5,0.5,0.5), BS*4); + */ f32 camera_yaw = 0; // "right/left" f32 camera_pitch = 0; // "up/down" diff --git a/src/mapblock.cpp b/src/mapblock.cpp index 1dbbe5c4..a1e3c669 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -255,32 +255,18 @@ void MapBlock::makeFastFace(TileSpec tile, u8 light, v3f p, video::SColor c = video::SColor(alpha,li,li,li); - face.vertices[0] = video::S3DVertex(vertex_pos[0], zerovector, c, - core::vector2d(abs_scale,1)); - face.vertices[1] = video::S3DVertex(vertex_pos[1], zerovector, c, - core::vector2d(0,1)); - face.vertices[2] = video::S3DVertex(vertex_pos[2], zerovector, c, - core::vector2d(0,0)); - face.vertices[3] = video::S3DVertex(vertex_pos[3], zerovector, c, - core::vector2d(abs_scale,0)); - - /*float x0 = (float)tile.tx/256.0; - float y0 = (float)tile.ty/256.0; - float w = ((float)tile.tw + 1.0)/256.0; - float h = ((float)tile.th + 1.0)/256.0;*/ - float x0 = tile.texture.pos.X; float y0 = tile.texture.pos.Y; float w = tile.texture.size.X; float h = tile.texture.size.Y; - face.vertices[0] = video::S3DVertex(vertex_pos[0], zerovector, c, + face.vertices[0] = video::S3DVertex(vertex_pos[0], v3f(0,1,0), c, core::vector2d(x0+w*abs_scale, y0+h)); - face.vertices[1] = video::S3DVertex(vertex_pos[1], zerovector, c, + face.vertices[1] = video::S3DVertex(vertex_pos[1], v3f(0,1,0), c, core::vector2d(x0, y0+h)); - face.vertices[2] = video::S3DVertex(vertex_pos[2], zerovector, c, + face.vertices[2] = video::S3DVertex(vertex_pos[2], v3f(0,1,0), c, core::vector2d(x0, y0)); - face.vertices[3] = video::S3DVertex(vertex_pos[3], zerovector, c, + face.vertices[3] = video::S3DVertex(vertex_pos[3], v3f(0,1,0), c, core::vector2d(x0+w*abs_scale, y0)); face.tile = tile; @@ -736,12 +722,11 @@ void MapBlock::updateMesh(u32 daynight_ratio) //TimeTaker timer2("updateMesh() mesh building"); video::SMaterial material; - material.Lighting = false; - //material.BackfaceCulling = false; + material.setFlag(video::EMF_LIGHTING, false); material.setFlag(video::EMF_BILINEAR_FILTER, false); + material.setFlag(video::EMF_FOG_ENABLE, true); //material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF); //material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_SIMPLE); - material.setFlag(video::EMF_FOG_ENABLE, true); for(u32 i=0; i reply(replysize); @@ -2131,76 +2130,21 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) */ core::map modified_blocks; m_env.getMap().addNodeAndUpdate(p_over, n, modified_blocks); -#endif -#if 0 + /* - Handle inventory - */ - InventoryList *ilist = player->inventory.getList("main"); - if(g_settings.getBool("creative_mode") == false && ilist) - { - // Remove from inventory and send inventory - if(mitem->getCount() == 1) - ilist->deleteItem(item_i); - else - mitem->remove(1); - // Send inventory - SendInventory(peer_id); - } - - /* - Add node. - - This takes some time so it is done after the quick stuff - */ - core::map modified_blocks; - m_env.getMap().addNodeAndUpdate(p_over, n, modified_blocks); - - /* - Set the modified blocks unsent for all the clients + Calculate special events */ - //JMutexAutoLock lock2(m_con_mutex); - - for(core::map::Iterator - i = m_clients.getIterator(); - i.atEnd() == false; i++) + /*if(n.d == CONTENT_MESE) { - RemoteClient *client = i.getNode()->getValue(); - - if(modified_blocks.size() > 0) + u32 count = 0; + for(s16 z=-1; z<=1; z++) + for(s16 y=-1; y<=1; y++) + for(s16 x=-1; x<=1; x++) { - // Remove block from sent history - client->SetBlocksNotSent(modified_blocks); + } - } -#endif - -#if 0 - /* - Update water - */ - - // Update water pressure around modification - // This also adds it to m_flow_active_nodes if appropriate - - MapVoxelManipulator v(&m_env.getMap()); - v.m_disable_water_climb = - g_settings.getBool("disable_water_climb"); - - VoxelArea area(p_over-v3s16(1,1,1), p_over+v3s16(1,1,1)); - - try - { - v.updateAreaWaterPressure(area, m_flow_active_nodes); - } - catch(ProcessingLimitException &e) - { - dstream<<"Processing limit reached (1)"<