From: Elias Fleckenstein Date: Thu, 5 Nov 2020 13:08:19 +0000 (+0100) Subject: MapBlockMesh Performance Improvement X-Git-Tag: 05-11-2020~2 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=6bda686c04e602c7e50d4838632d92c55b228c36;p=dragonfireclient.git MapBlockMesh Performance Improvement --- diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 537ee414d..f65864599 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -820,8 +820,7 @@ static void getTileInfo( TileSpec &tile, // lol more Input bool xray, - std::set xraySet, - std::set nodeESPSet) + std::set xraySet) { VoxelManipulator &vmanip = data->m_vmanip; const NodeDefManager *ndef = data->m_client->ndef(); @@ -832,8 +831,6 @@ static void getTileInfo( content_t c0 = n0.getContent(); if (xray && xraySet.find(c0) != xraySet.end()) c0 = CONTENT_AIR; - if (nodeESPSet.find(c0) != nodeESPSet.end()) - data->m_esp_nodes.insert(blockpos_nodes + p); // Don't even try to get n1 if n0 is already CONTENT_IGNORE if (c0 == CONTENT_IGNORE) { makes_face = false; @@ -911,8 +908,7 @@ static void updateFastFaceRow( const v3s16 &&face_dir, std::vector &dest, bool xray, - std::set xraySet, - std::set nodeESPSet) + std::set xraySet) { static thread_local const bool waving_liquids = g_settings->getBool("enable_shaders") && @@ -932,7 +928,7 @@ static void updateFastFaceRow( // Get info of first tile getTileInfo(data, p, face_dir, makes_face, p_corrected, face_dir_corrected, - lights, waving, tile, xray, xraySet, nodeESPSet); + lights, waving, tile, xray, xraySet); // Unroll this variable which has a significant build cost TileSpec next_tile; @@ -956,8 +952,7 @@ static void updateFastFaceRow( waving, next_tile, xray, - xraySet, - nodeESPSet); + xraySet); if (next_makes_face == makes_face && next_p_corrected == p_corrected + translate_dir @@ -1007,7 +1002,7 @@ static void updateFastFaceRow( } static void updateAllFastFaceRows(MeshMakeData *data, - std::vector &dest, bool xray, std::set xraySet, std::set nodeESPSet) + std::vector &dest, bool xray, std::set xraySet) { /* Go through every y,z and get top(y+) faces in rows of x+ @@ -1021,8 +1016,7 @@ static void updateAllFastFaceRows(MeshMakeData *data, v3s16(0, 1, 0), //face dir dest, xray, - xraySet, - nodeESPSet); + xraySet); /* Go through every x,y and get right(x+) faces in rows of z+ @@ -1036,8 +1030,7 @@ static void updateAllFastFaceRows(MeshMakeData *data, v3s16(1, 0, 0), //face dir dest, xray, - xraySet, - nodeESPSet); + xraySet); /* Go through every y,z and get back(z+) faces in rows of x+ @@ -1051,8 +1044,7 @@ static void updateAllFastFaceRows(MeshMakeData *data, v3s16(0, 0, 1), //face dir dest, xray, - xraySet, - nodeESPSet); + xraySet); } static void applyTileColor(PreMeshBuffer &pmb) @@ -1119,10 +1111,27 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): { // 4-23ms for MAP_BLOCKSIZE=16 (NOTE: probably outdated) //TimeTaker timer2("updateAllFastFaceRows()"); - updateAllFastFaceRows(data, fastfaces_new, xray, xraySet, nodeESPSet); + updateAllFastFaceRows(data, fastfaces_new, xray, xraySet); } // End of slow part + /* + NodeESP + */ + { + v3s16 blockpos_nodes = data->m_blockpos * MAP_BLOCKSIZE; + for (s16 x = 0; x < MAP_BLOCKSIZE; x++) { + for (s16 y = 0; y < MAP_BLOCKSIZE; y++) { + for (s16 z = 0; z < MAP_BLOCKSIZE; z++) { + v3s16 pos = v3s16(x, y, z) + blockpos_nodes; + const MapNode &node = data->m_vmanip.getNodeRefUnsafeCheckFlags(pos); + if (nodeESPSet.find(node.getContent()) != nodeESPSet.end()) + esp_nodes.insert(pos); + } + } + } + } + /* Convert FastFaces to MeshCollector */ @@ -1305,8 +1314,6 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): !m_crack_materials.empty() || !m_daynight_diffs.empty() || !m_animation_tiles.empty(); - - esp_nodes = data->m_esp_nodes; } MapBlockMesh::~MapBlockMesh() diff --git a/src/client/mapblock_mesh.h b/src/client/mapblock_mesh.h index 67fb94976..95fda83e5 100644 --- a/src/client/mapblock_mesh.h +++ b/src/client/mapblock_mesh.h @@ -46,7 +46,6 @@ struct MeshMakeData Client *m_client; bool m_use_shaders; bool m_use_tangent_vertices; - std::set m_esp_nodes; MeshMakeData(Client *client, bool use_shaders, bool use_tangent_vertices = false); diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index 9f1a104ba..8ea1a0283 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -529,7 +529,7 @@ void Minimap::drawMinimap() driver->setViewPort(oldViewPort); // Draw player markers - v2s32 s_pos(screensize.X - size - 10, 10); + v2s32 s_pos(screensize.X - size * 2 - 10, 10); core::dimension2di imgsize(data->object_marker_red->getOriginalSize()); core::rect img_rect(0, 0, imgsize.Width, imgsize.Height); static const video::SColor col(255, 255, 255, 255); diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index 7d4c1e748..210363417 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -1837,9 +1837,10 @@ void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm, } else if (pointed.type == POINTEDTHING_OBJECT) { lua_pushstring(L, "object"); lua_setfield(L, -2, "type"); - if (csm) { +#ifndef SERVER ClientObjectRef::create(L, pointed.object_id); +#endif } else { push_objectRef(L, pointed.object_id); }