diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 95fd47dc..f0535e14 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -324,7 +324,7 @@ void Hud::update(bool visible) { const auto& chunks = *player.chunks; const auto& menu = gui.getMenu(); - debugPanel->setVisible(player.debug && visible); + debugPanel->setVisible(debug && visible); if (!visible && inventoryOpen) { closeInventory(); @@ -359,7 +359,7 @@ void Hud::update(bool visible) { if (visible) { for (auto& element : elements) { - element.update(pause, inventoryOpen, player.debug); + element.update(pause, inventoryOpen, debug); if (element.isRemoved()) { onRemove(element); } @@ -367,8 +367,8 @@ void Hud::update(bool visible) { } cleanup(); - debugMinimap->setVisible(player.debug && showGeneratorMinimap); - if (player.debug && showGeneratorMinimap) { + debugMinimap->setVisible(debug && showGeneratorMinimap); + if (debug && showGeneratorMinimap) { updateWorldGenDebugVisualization(); } } @@ -585,6 +585,10 @@ void Hud::remove(const std::shared_ptr& node) { cleanup(); } +void Hud::setDebug(bool flag) { + debug = flag; +} + void Hud::draw(const DrawContext& ctx){ const Viewport& viewport = ctx.getViewport(); const uint width = viewport.getWidth(); @@ -602,7 +606,7 @@ void Hud::draw(const DrawContext& ctx){ uishader.uniformMatrix("u_projview", uicamera->getProjView()); // Crosshair - if (!pause && !inventoryOpen && !player.debug) { + if (!pause && !inventoryOpen && !debug) { DrawContext chctx = ctx.sub(batch); chctx.setBlendMode(BlendMode::inversion); auto texture = assets.get("gui/crosshair"); diff --git a/src/frontend/hud.hpp b/src/frontend/hud.hpp index 79d183fa..2a537157 100644 --- a/src/frontend/hud.hpp +++ b/src/frontend/hud.hpp @@ -113,6 +113,7 @@ class Hud : public util::ObjectsKeeper { bool showContentPanel = true; /// @brief Provide cheat controllers to the debug panel bool allowDebugCheats = true; + bool debug = false; /// @brief UI element will be dynamicly positioned near to inventory or in screen center std::shared_ptr secondUI; @@ -193,6 +194,8 @@ public: void onRemove(const HudElement& element); void remove(const std::shared_ptr& node); + void setDebug(bool flag); + Player* getPlayer() const; std::shared_ptr getBlockInventory(); diff --git a/src/frontend/screens/LevelScreen.cpp b/src/frontend/screens/LevelScreen.cpp index 8a37b903..5fc073b3 100644 --- a/src/frontend/screens/LevelScreen.cpp +++ b/src/frontend/screens/LevelScreen.cpp @@ -157,7 +157,9 @@ void LevelScreen::updateHotkeys() { hudVisible = !hudVisible; } if (Events::jpressed(keycode::F3)) { - player->debug = !player->debug; + debug = !debug; + hud->setDebug(debug); + worldRenderer->setDebug(debug); } } diff --git a/src/frontend/screens/LevelScreen.hpp b/src/frontend/screens/LevelScreen.hpp index c184f816..6a3b4eab 100644 --- a/src/frontend/screens/LevelScreen.hpp +++ b/src/frontend/screens/LevelScreen.hpp @@ -29,6 +29,7 @@ class LevelScreen : public Screen { void saveWorldPreview(); bool hudVisible = true; + bool debug = false; void updateHotkeys(); void initializeContent(); void initializePack(ContentPackRuntime* pack); diff --git a/src/graphics/render/WorldRenderer.cpp b/src/graphics/render/WorldRenderer.cpp index e8a75f0c..098cb8e8 100644 --- a/src/graphics/render/WorldRenderer.cpp +++ b/src/graphics/render/WorldRenderer.cpp @@ -211,7 +211,7 @@ void WorldRenderer::renderBlockSelection() { lineBatch->box( center, size + glm::vec3(0.01), glm::vec4(0.f, 0.f, 0.f, 0.5f) ); - if (player.debug) { + if (debug) { lineBatch->line( point, point + norm * 0.5f, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f) ); @@ -228,7 +228,7 @@ void WorldRenderer::renderLines( if (player.selection.vox.id != BLOCK_VOID) { renderBlockSelection(); } - if (player.debug && showEntitiesDebug) { + if (debug && showEntitiesDebug) { auto ctx = pctx.sub(lineBatch.get()); bool culling = engine.getSettings().graphics.frustumCulling.get(); level.entities->renderDebug( @@ -337,7 +337,7 @@ void WorldRenderer::draw( renderLevel(ctx, camera, settings, delta, pause, hudVisible); // Debug lines if (hudVisible) { - if (player.debug) { + if (debug) { guides->renderDebugLines( ctx, camera, *lineBatch, linesShader, showChunkBorders ); @@ -410,3 +410,7 @@ void WorldRenderer::renderBlockOverlay(const DrawContext& wctx) { void WorldRenderer::clear() { chunks->clear(); } + +void WorldRenderer::setDebug(bool flag) { + debug = flag; +} diff --git a/src/graphics/render/WorldRenderer.hpp b/src/graphics/render/WorldRenderer.hpp index f8be0177..569858d8 100644 --- a/src/graphics/render/WorldRenderer.hpp +++ b/src/graphics/render/WorldRenderer.hpp @@ -45,6 +45,7 @@ class WorldRenderer { std::unique_ptr modelBatch; float timer = 0.0f; + bool debug = false; /// @brief Render block selection lines void renderBlockSelection(); @@ -100,4 +101,6 @@ public: ); void clear(); + + void setDebug(bool flag); }; diff --git a/src/logic/ChunksController.cpp b/src/logic/ChunksController.cpp index 162ca2fe..a228de61 100644 --- a/src/logic/ChunksController.cpp +++ b/src/logic/ChunksController.cpp @@ -39,6 +39,7 @@ void ChunksController::update( int centerY = floordiv(position.z); if (player.isLoadingChunks()) { + /// FIXME: one generator for multiple players generator->update(centerX, centerY, loadDistance); } diff --git a/src/objects/Player.hpp b/src/objects/Player.hpp index 447b1eab..b7ace8ff 100644 --- a/src/objects/Player.hpp +++ b/src/objects/Player.hpp @@ -55,10 +55,9 @@ class Player : public Serializable { entityid_t eid; entityid_t selectedEid = 0; public: - std::unique_ptr chunks; // not in use yet + std::unique_ptr chunks; std::shared_ptr fpCamera, spCamera, tpCamera; - std::shared_ptr currentCamera; - bool debug = false; + std::shared_ptr currentCamera;; glm::vec3 cam {}; CursorSelection selection {};