diff options
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/game.cpp | 6 | ||||
-rw-r--r-- | src/client/mapblock_mesh.cpp | 30 | ||||
-rw-r--r-- | src/client/mapblock_mesh.h | 2 | ||||
-rw-r--r-- | src/client/minimap.cpp | 6 | ||||
-rw-r--r-- | src/client/render/core.cpp | 82 | ||||
-rw-r--r-- | src/client/render/core.h | 8 | ||||
-rw-r--r-- | src/client/renderingengine.cpp | 4 | ||||
-rw-r--r-- | src/client/renderingengine.h | 7 |
8 files changed, 103 insertions, 42 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp index 479484ae9..2e8a50294 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -116,6 +116,8 @@ Game::Game() : &updateAllMapBlocksCallback, this); g_settings->registerChangedCallback("fullbright", &updateAllMapBlocksCallback, this); + g_settings->registerChangedCallback("node_esp_nodes", + &updateAllMapBlocksCallback, this); readSettings(); @@ -182,6 +184,8 @@ Game::~Game() &updateAllMapBlocksCallback, this); g_settings->deregisterChangedCallback("fullbright", &updateAllMapBlocksCallback, this); + g_settings->deregisterChangedCallback("node_esp_nodes", + &updateAllMapBlocksCallback, this); } bool Game::startup(bool *kill, @@ -3194,7 +3198,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, } #endif RenderingEngine::draw_scene(skycolor, m_game_ui->m_flags.show_hud, - m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair, g_settings->getBool("enable_tracers"), g_settings->getBool("enable_esp")); + m_game_ui->m_flags.show_minimap, draw_wield_tool, draw_crosshair, g_settings->getBool("enable_esp"), g_settings->getBool("enable_tracers"), g_settings->getBool("enable_node_esp"), g_settings->getBool("enable_node_tracers")); /* Profiler graph diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index fbd7e2ab7..f65864599 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -818,9 +818,9 @@ static void getTileInfo( u16 *lights, u8 &waving, TileSpec &tile, + // lol more Input bool xray, - std::set<content_t> xraySet - ) + std::set<content_t> xraySet) { VoxelManipulator &vmanip = data->m_vmanip; const NodeDefManager *ndef = data->m_client->ndef(); @@ -831,7 +831,6 @@ static void getTileInfo( content_t c0 = n0.getContent(); if (xray && xraySet.find(c0) != xraySet.end()) c0 = CONTENT_AIR; - // Don't even try to get n1 if n0 is already CONTENT_IGNORE if (c0 == CONTENT_IGNORE) { makes_face = false; @@ -946,7 +945,7 @@ static void updateFastFaceRow( // the face must be drawn anyway if (j != MAP_BLOCKSIZE - 1) { p += translate_dir; - + getTileInfo(data, p, face_dir, next_makes_face, next_p_corrected, next_face_dir_corrected, next_lights, @@ -954,7 +953,7 @@ static void updateFastFaceRow( next_tile, xray, xraySet); - + if (next_makes_face == makes_face && next_p_corrected == p_corrected + translate_dir && next_face_dir_corrected == face_dir_corrected @@ -1096,10 +1095,12 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): X-Ray */ bool xray = g_settings->getBool("xray"); - std::set<content_t> xraySet; + std::set<content_t> xraySet, nodeESPSet; if (xray) xraySet = splitToContentT(g_settings->get("xray_nodes"), data->m_client->ndef()); + nodeESPSet = splitToContentT(g_settings->get("node_esp_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 @@ -1115,6 +1116,23 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data, v3s16 camera_offset): // 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 */ diff --git a/src/client/mapblock_mesh.h b/src/client/mapblock_mesh.h index 6af23a656..95fda83e5 100644 --- a/src/client/mapblock_mesh.h +++ b/src/client/mapblock_mesh.h @@ -134,6 +134,8 @@ public: void updateCameraOffset(v3s16 camera_offset); + std::set<v3s16> esp_nodes; + private: scene::IMesh *m_mesh[MAX_TILE_LAYERS]; MinimapMapblock *m_minimap_mapblock; diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index 68770ec19..8ea1a0283 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -474,8 +474,8 @@ void Minimap::drawMinimap() core::matrix4 oldViewMat = driver->getTransform(video::ETS_VIEW); driver->setViewPort(core::rect<s32>( - screensize.X - size - 10, 10, - screensize.X - 10, size + 10)); + screensize.X - size * 2 - 10, 10, + screensize.X - size - 10, size + 10)); driver->setTransform(video::ETS_PROJECTION, core::matrix4()); driver->setTransform(video::ETS_VIEW, core::matrix4()); @@ -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<s32> img_rect(0, 0, imgsize.Width, imgsize.Height); static const video::SColor col(255, 255, 255, 255); diff --git a/src/client/render/core.cpp b/src/client/render/core.cpp index 223af5142..cb4f1deb7 100644 --- a/src/client/render/core.cpp +++ b/src/client/render/core.cpp @@ -26,6 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "client/hud.h" #include "client/minimap.h" #include "client/content_cao.h" +#include "mapblock.h" +#include "mapsector.h" RenderingCore::RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud) : device(_device), driver(device->getVideoDriver()), smgr(device->getSceneManager()), @@ -55,7 +57,7 @@ void RenderingCore::updateScreenSize() } void RenderingCore::draw(video::SColor _skycolor, bool _show_hud, bool _show_minimap, - bool _draw_wield_tool, bool _draw_crosshair, bool _draw_tracers, bool _draw_esp) + bool _draw_wield_tool, bool _draw_crosshair, bool _draw_esp, bool _draw_tracers, bool _draw_node_esp, bool _draw_node_tracers) { v2u32 ss = driver->getScreenSize(); if (screensize != ss) { @@ -67,8 +69,10 @@ void RenderingCore::draw(video::SColor _skycolor, bool _show_hud, bool _show_min show_minimap = _show_minimap; draw_wield_tool = _draw_wield_tool; draw_crosshair = _draw_crosshair; - draw_tracers = _draw_tracers; draw_esp = _draw_esp; + draw_tracers = _draw_tracers; + draw_node_esp = _draw_node_esp; + draw_node_tracers = _draw_node_tracers; beforeDraw(); drawAll(); @@ -91,26 +95,58 @@ void RenderingCore::drawTracersAndESP() material.setFlag(video::EMF_ZWRITE_ENABLE, false); driver->setMaterial(material); - auto allObjects = env.getAllActiveObjects(); - for (auto &it : allObjects) { - ClientActiveObject *cao = it.second; - if (cao->isLocalPlayer() || cao->getParent()) - continue; - GenericCAO *obj = dynamic_cast<GenericCAO *>(cao); - if (! obj) - continue; - aabb3f box; - if (! obj->getSelectionBox(&box)) - continue; - v3f pos = obj->getPosition(); - pos -= camera_offset; - box.MinEdge += pos; - box.MaxEdge += pos; - pos = box.getCenter(); - if (draw_esp) - driver->draw3DBox(box, video::SColor(255, 255, 255, 255)); - if (draw_tracers) - driver->draw3DLine(eye_pos, pos, video::SColor(255, 255, 255, 255)); + if (draw_esp || draw_tracers) { + auto allObjects = env.getAllActiveObjects(); + + for (auto &it : allObjects) { + ClientActiveObject *cao = it.second; + if (cao->isLocalPlayer() || cao->getParent()) + continue; + GenericCAO *obj = dynamic_cast<GenericCAO *>(cao); + if (! obj) + continue; + aabb3f box; + if (! obj->getSelectionBox(&box)) + continue; + v3f pos = obj->getPosition() - camera_offset; + box.MinEdge += pos; + box.MaxEdge += pos; + if (draw_esp) + driver->draw3DBox(box, video::SColor(255, 255, 255, 255)); + if (draw_tracers) + driver->draw3DLine(eye_pos, box.getCenter(), video::SColor(255, 255, 255, 255)); + } + } + if (draw_node_esp || draw_node_tracers) { + Map &map = env.getMap(); + std::map<v2s16, MapSector*> *sectors = map.getSectorsPtr(); + + for (auto §or_it : *sectors) { + MapSector *sector = sector_it.second; + MapBlockVect blocks; + sector->getBlocks(blocks); + for (MapBlock *block : blocks) { + if (! block->mesh) + continue; + for (v3s16 p : block->mesh->esp_nodes) { + v3f pos = intToFloat(p, BS) - camera_offset; + MapNode node = map.getNode(p); + std::vector<aabb3f> boxes; + node.getSelectionBoxes(client->getNodeDefManager(), &boxes, node.getNeighbors(p, &map)); + video::SColor color = client->getNodeDefManager()->get(node).minimap_color; + + for (aabb3f box : boxes) { + box.MinEdge += pos; + box.MaxEdge += pos; + if (draw_node_esp) + driver->draw3DBox(box, color); + if (draw_node_tracers) + driver->draw3DLine(eye_pos, box.getCenter(), color); + } + } + } + } + } driver->setMaterial(oldmaterial); @@ -123,7 +159,7 @@ void RenderingCore::draw3D() if (!show_hud) return; hud->drawSelectionMesh(); - if (draw_tracers || draw_esp) + if (draw_esp || draw_tracers || draw_node_esp || draw_node_tracers) drawTracersAndESP(); if (draw_wield_tool) camera->drawWieldedTool(); diff --git a/src/client/render/core.h b/src/client/render/core.h index 90b81b060..2040155a6 100644 --- a/src/client/render/core.h +++ b/src/client/render/core.h @@ -36,8 +36,10 @@ protected: bool show_minimap; bool draw_wield_tool; bool draw_crosshair; - bool draw_tracers; bool draw_esp; + bool draw_tracers; + bool draw_node_esp; + bool draw_node_tracers; IrrlichtDevice *device; video::IVideoDriver *driver; @@ -72,8 +74,8 @@ public: void initialize(); void draw(video::SColor _skycolor, bool _show_hud, bool _show_minimap, - bool _draw_wield_tool, bool _draw_crosshair, bool _draw_tracers, - bool _draw_esp); + bool _draw_wield_tool, bool _draw_crosshair, bool _draw_esp, + bool _draw_tracers, bool _draw_node_esp, bool _draw_node_tracers); inline v2u32 getVirtualSize() const { return virtual_size; } }; diff --git a/src/client/renderingengine.cpp b/src/client/renderingengine.cpp index 1534289d4..e6d25d4ee 100644 --- a/src/client/renderingengine.cpp +++ b/src/client/renderingengine.cpp @@ -604,9 +604,9 @@ void RenderingEngine::_finalize() } void RenderingEngine::_draw_scene(video::SColor skycolor, bool show_hud, - bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp) + bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_esp, bool draw_tracers, bool draw_node_esp, bool draw_node_tracers) { - core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair, draw_tracers, draw_esp); + core->draw(skycolor, show_hud, show_minimap, draw_wield_tool, draw_crosshair, draw_esp, draw_tracers, draw_node_esp, draw_node_tracers); } const char *RenderingEngine::getVideoDriverName(irr::video::E_DRIVER_TYPE type) diff --git a/src/client/renderingengine.h b/src/client/renderingengine.h index c5fa8918b..99aa3c678 100644 --- a/src/client/renderingengine.h +++ b/src/client/renderingengine.h @@ -32,7 +32,6 @@ class Client; class LocalPlayer; class Hud; class Minimap; -class Tracers; class RenderingCore; @@ -118,10 +117,10 @@ public: } inline static void draw_scene(video::SColor skycolor, bool show_hud, - bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp) + bool show_minimap, bool draw_wield_tool, bool draw_crosshair, bool draw_esp, bool draw_tracers, bool draw_node_esp, bool draw_node_tracers) { s_singleton->_draw_scene(skycolor, show_hud, show_minimap, - draw_wield_tool, draw_crosshair, draw_tracers, draw_esp); + draw_wield_tool, draw_crosshair, draw_esp, draw_tracers, draw_node_esp, draw_node_tracers); } inline static void initialize(Client *client, Hud *hud) @@ -149,7 +148,7 @@ private: bool clouds = true); void _draw_scene(video::SColor skycolor, bool show_hud, bool show_minimap, - bool draw_wield_tool, bool draw_crosshair, bool draw_tracers, bool draw_esp); + bool draw_wield_tool, bool draw_crosshair, bool draw_esp, bool draw_tracers, bool draw_node_esp, bool draw_node_tracers); void _initialize(Client *client, Hud *hud); |