add "Show Hitboxes" to the debug panel

This commit is contained in:
MihailRis 2024-07-06 05:36:16 +03:00
parent 9efb327270
commit 5522cfc231
3 changed files with 16 additions and 1 deletions

View File

@ -33,6 +33,7 @@ static std::shared_ptr<Label> create_label(wstringsupplier supplier) {
return label;
}
// TODO: move to xml
std::shared_ptr<UINode> create_debug_panel(
Engine* engine,
Level* level,
@ -181,6 +182,18 @@ std::shared_ptr<UINode> create_debug_panel(
});
panel->add(checkbox);
}
{
auto checkbox = std::make_shared<FullCheckBox>(
L"Show Hitboxes", glm::vec2(400, 24)
);
checkbox->setSupplier([=]() {
return WorldRenderer::showEntitiesDebug;
});
checkbox->setConsumer([=](bool checked) {
WorldRenderer::showEntitiesDebug = checked;
});
panel->add(checkbox);
}
panel->refresh();
return panel;
}

View File

@ -44,6 +44,7 @@
#include <glm/gtc/matrix_transform.hpp>
bool WorldRenderer::showChunkBorders = false;
bool WorldRenderer::showEntitiesDebug = false;
WorldRenderer::WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* player)
: engine(engine),
@ -232,7 +233,7 @@ void WorldRenderer::renderLines(Camera* camera, Shader* linesShader) {
if (player->selection.vox.id != BLOCK_VOID) {
renderBlockSelection();
}
if (player->debug) {
if (player->debug && showEntitiesDebug) {
level->entities->renderDebug(*lineBatch, *frustumCulling);
}
lineBatch->render();

View File

@ -63,6 +63,7 @@ class WorldRenderer {
);
public:
static bool showChunkBorders;
static bool showEntitiesDebug;
WorldRenderer(Engine* engine, LevelFrontend* frontend, Player* player);
~WorldRenderer();