diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client/client.cpp | 7 | ||||
-rw-r--r-- | src/client/game.cpp | 4 | ||||
-rw-r--r-- | src/client/mapblock_mesh.cpp | 65 | ||||
-rw-r--r-- | src/defaultsettings.cpp | 2 |
4 files changed, 58 insertions, 20 deletions
diff --git a/src/client/client.cpp b/src/client/client.cpp index d3e7a278d..aa3e257ac 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -1664,9 +1664,12 @@ void Client::addUpdateMeshTaskForNode(v3s16 nodepos, bool ack_to_server, bool ur void Client::updateAllMapBlocks() { - v3s16 currentBlock = getNodeBlockPos(floatToInt(m_env.getLocalPlayer()->getPosition(), BS)); - addUpdateMeshTaskWithEdge(currentBlock, false, true); + + for (s16 X = currentBlock.X - 2; X <= currentBlock.X + 2; X++) + for (s16 Y = currentBlock.Y - 2; Y <= currentBlock.Y + 2; Y++) + for (s16 Z = currentBlock.Z - 2; Z <= currentBlock.Z + 2; Z++) + addUpdateMeshTask(v3s16(X, Y, Z), false, true); std::map<v2s16, MapSector*> *sectors = m_env.getMap().getSectorsPtr(); diff --git a/src/client/game.cpp b/src/client/game.cpp index f229363c8..d983e2bb8 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -112,7 +112,7 @@ Game::Game() : &freecamChangedCallback, this); g_settings->registerChangedCallback("xray", &updateAllMapBlocksCallback, this); - g_settings->registerChangedCallback("xray_node", + g_settings->registerChangedCallback("xray_nodes", &updateAllMapBlocksCallback, this); g_settings->registerChangedCallback("fullbright", &updateAllMapBlocksCallback, this); @@ -178,7 +178,7 @@ Game::~Game() &freecamChangedCallback, this); g_settings->deregisterChangedCallback("xray", &updateAllMapBlocksCallback, this); - g_settings->deregisterChangedCallback("xray_node", + g_settings->deregisterChangedCallback("xray_nodes", &updateAllMapBlocksCallback, this); g_settings->deregisterChangedCallback("fullbright", &updateAllMapBlocksCallback, this); diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 6efdb5f2e..fbd7e2ab7 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -788,6 +788,24 @@ void getNodeTile(MapNode mn, const v3s16 &p, const v3s16 &dir, MeshMakeData *dat tile.rotation = tile.world_aligned ? 0 : dir_to_tile[tile_index + 1]; } +std::set<content_t> splitToContentT(std::string str, const NodeDefManager *ndef) +{ + str += "\n"; + std::set<content_t> dat; + std::string buf; + for (char c : str) { + if (c == ',' || c == '\n') { + if (! buf.empty()) { + dat.insert(ndef->getId(buf)); + } + buf.clear(); + } else if (c != ' ') { + buf += c; + } + } + return dat; +} + static void getTileInfo( // Input: MeshMakeData *data, @@ -799,19 +817,19 @@ static void getTileInfo( v3s16 &face_dir_corrected, u16 *lights, u8 &waving, - TileSpec &tile + TileSpec &tile, + bool xray, + std::set<content_t> xraySet ) { VoxelManipulator &vmanip = data->m_vmanip; const NodeDefManager *ndef = data->m_client->ndef(); v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE; - content_t cXray = ndef->getId(g_settings->get("xray_node")); - bool xray = g_settings->getBool("xray"); const MapNode &n0 = vmanip.getNodeRefUnsafe(blockpos_nodes + p); content_t c0 = n0.getContent(); - if (xray && c0 == cXray) + if (xray && xraySet.find(c0) != xraySet.end()) c0 = CONTENT_AIR; // Don't even try to get n1 if n0 is already CONTENT_IGNORE @@ -823,7 +841,7 @@ static void getTileInfo( const MapNode &n1 = vmanip.getNodeRefUnsafeCheckFlags(blockpos_nodes + p + face_dir); content_t c1 = n1.getContent(); - if (xray && c1 == cXray) + if (xray && xraySet.find(c1) != xraySet.end()) c1 = CONTENT_AIR; if (c1 == CONTENT_IGNORE) { @@ -889,7 +907,9 @@ static void updateFastFaceRow( v3s16 translate_dir, const v3f &&translate_dir_f, const v3s16 &&face_dir, - std::vector<FastFace> &dest) + std::vector<FastFace> &dest, + bool xray, + std::set<content_t> xraySet) { static thread_local const bool waving_liquids = g_settings->getBool("enable_shaders") && @@ -909,7 +929,7 @@ static void updateFastFaceRow( // Get info of first tile getTileInfo(data, p, face_dir, makes_face, p_corrected, face_dir_corrected, - lights, waving, tile); + lights, waving, tile, xray, xraySet); // Unroll this variable which has a significant build cost TileSpec next_tile; @@ -931,7 +951,9 @@ static void updateFastFaceRow( next_makes_face, next_p_corrected, next_face_dir_corrected, next_lights, waving, - next_tile); + next_tile, + xray, + xraySet); if (next_makes_face == makes_face && next_p_corrected == p_corrected + translate_dir @@ -981,7 +1003,7 @@ static void updateFastFaceRow( } static void updateAllFastFaceRows(MeshMakeData *data, - std::vector<FastFace> &dest) + std::vector<FastFace> &dest, bool xray, std::set<content_t> xraySet) { /* Go through every y,z and get top(y+) faces in rows of x+ @@ -993,7 +1015,9 @@ static void updateAllFastFaceRows(MeshMakeData *data, v3s16(1, 0, 0), //dir v3f (1, 0, 0), v3s16(0, 1, 0), //face dir - dest); + dest, + xray, + xraySet); /* Go through every x,y and get right(x+) faces in rows of z+ @@ -1005,7 +1029,9 @@ static void updateAllFastFaceRows(MeshMakeData *data, v3s16(0, 0, 1), //dir v3f (0, 0, 1), v3s16(1, 0, 0), //face dir - dest); + dest, + xray, + xraySet); /* Go through every y,z and get back(z+) faces in rows of x+ @@ -1017,7 +1043,9 @@ static void updateAllFastFaceRows(MeshMakeData *data, v3s16(1, 0, 0), //dir v3f (1, 0, 0), v3s16(0, 0, 1), //face dir - dest); + dest, + xray, + xraySet); } static void applyTileColor(PreMeshBuffer &pmb) @@ -1064,18 +1092,25 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): std::vector<FastFace> fastfaces_new; fastfaces_new.reserve(512); - + /* + X-Ray + */ + bool xray = g_settings->getBool("xray"); + std::set<content_t> xraySet; + if (xray) + xraySet = splitToContentT(g_settings->get("xray_nodes"), data->m_client->ndef()); + /* We are including the faces of the trailing edges of the block. This means that when something changes, the caller must also update the meshes of the blocks at the leading edges. NOTE: This is the slowest part of this method. - */ + */ { // 4-23ms for MAP_BLOCKSIZE=16 (NOTE: probably outdated) //TimeTaker timer2("updateAllFastFaceRows()"); - updateAllFastFaceRows(data, fastfaces_new); + updateAllFastFaceRows(data, fastfaces_new, xray, xraySet); } // End of slow part diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index bb54dc950..91d9d6be6 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -66,7 +66,7 @@ void set_default_settings(Settings *settings) // Cheats settings->setDefault("xray", "false"); - settings->setDefault("xray_node", "default:stone"); + settings->setDefault("xray_nodes", "default:stone,mcl_core:stone"); settings->setDefault("fullbright", "false"); settings->setDefault("priv_bypass", "true"); settings->setDefault("fastdig", "false"); |