aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/game.cpp2
-rw-r--r--src/client/hud.cpp48
-rw-r--r--src/client/hud.h11
-rw-r--r--src/client/inputhandler.cpp1
-rw-r--r--src/client/keys.h1
-rw-r--r--src/client/render/core.cpp1
6 files changed, 64 insertions, 0 deletions
diff --git a/src/client/game.cpp b/src/client/game.cpp
index edb054032..b092b95e2 100644
--- a/src/client/game.cpp
+++ b/src/client/game.cpp
@@ -1932,6 +1932,8 @@ void Game::processKeyInput()
toggleCinematic();
} else if (wasKeyDown(KeyType::SCREENSHOT)) {
client->makeScreenshot();
+ } else if (wasKeyDown(KeyType::TOGGLE_BLOCK_BOUNDS)) {
+ hud->toggleBlockBounds();
} else if (wasKeyDown(KeyType::TOGGLE_HUD)) {
m_game_ui->toggleHud();
} else if (wasKeyDown(KeyType::MINIMAP)) {
diff --git a/src/client/hud.cpp b/src/client/hud.cpp
index 6d332490c..c58c7e822 100644
--- a/src/client/hud.cpp
+++ b/src/client/hud.cpp
@@ -862,6 +862,54 @@ void Hud::drawSelectionMesh()
}
}
+void Hud::toggleBlockBounds()
+{
+ m_block_bounds_mode = static_cast<BlockBoundsMode>(m_block_bounds_mode + 1);
+
+ if (m_block_bounds_mode >= BLOCK_BOUNDS_MAX) {
+ m_block_bounds_mode = BLOCK_BOUNDS_OFF;
+ }
+}
+
+void Hud::drawBlockBounds()
+{
+ if (m_block_bounds_mode == BLOCK_BOUNDS_OFF) {
+ return;
+ }
+
+ video::SMaterial old_material = driver->getMaterial2D();
+ driver->setMaterial(m_selection_material);
+
+ v3s16 pos = player->getStandingNodePos();
+
+ v3s16 blockPos(
+ floorf((float) pos.X / MAP_BLOCKSIZE),
+ floorf((float) pos.Y / MAP_BLOCKSIZE),
+ floorf((float) pos.Z / MAP_BLOCKSIZE)
+ );
+
+ v3f offset = intToFloat(client->getCamera()->getOffset(), BS);
+
+ s8 radius = m_block_bounds_mode == BLOCK_BOUNDS_ALL ? 2 : 0;
+
+ v3f halfNode = v3f(BS, BS, BS) / 2.0f;
+
+ for (s8 x = -radius; x <= radius; x++)
+ for (s8 y = -radius; y <= radius; y++)
+ for (s8 z = -radius; z <= radius; z++) {
+ v3s16 blockOffset(x, y, z);
+
+ aabb3f box(
+ intToFloat((blockPos + blockOffset) * MAP_BLOCKSIZE, BS) - offset - halfNode,
+ intToFloat(((blockPos + blockOffset) * MAP_BLOCKSIZE) + (MAP_BLOCKSIZE - 1), BS) - offset + halfNode
+ );
+
+ driver->draw3DBox(box, video::SColor(255, 255, 0, 0));
+ }
+
+ driver->setMaterial(old_material);
+}
+
void Hud::updateSelectionMesh(const v3s16 &camera_offset)
{
m_camera_offset = camera_offset;
diff --git a/src/client/hud.h b/src/client/hud.h
index d46545d71..7046a16fb 100644
--- a/src/client/hud.h
+++ b/src/client/hud.h
@@ -59,6 +59,9 @@ public:
Inventory *inventory);
~Hud();
+ void toggleBlockBounds();
+ void drawBlockBounds();
+
void drawHotbar(u16 playeritem);
void resizeHotbar();
void drawCrosshair();
@@ -125,6 +128,14 @@ private:
scene::SMeshBuffer m_rotation_mesh_buffer;
+ enum BlockBoundsMode
+ {
+ BLOCK_BOUNDS_OFF,
+ BLOCK_BOUNDS_CURRENT,
+ BLOCK_BOUNDS_ALL,
+ BLOCK_BOUNDS_MAX
+ } m_block_bounds_mode = BLOCK_BOUNDS_OFF;
+
enum
{
HIGHLIGHT_BOX,
diff --git a/src/client/inputhandler.cpp b/src/client/inputhandler.cpp
index b7e70fa6c..980765efa 100644
--- a/src/client/inputhandler.cpp
+++ b/src/client/inputhandler.cpp
@@ -60,6 +60,7 @@ void KeyCache::populate()
key[KeyType::DEC_VOLUME] = getKeySetting("keymap_decrease_volume");
key[KeyType::CINEMATIC] = getKeySetting("keymap_cinematic");
key[KeyType::SCREENSHOT] = getKeySetting("keymap_screenshot");
+ key[KeyType::TOGGLE_BLOCK_BOUNDS] = getKeySetting("keymap_toggle_block_bounds");
key[KeyType::TOGGLE_HUD] = getKeySetting("keymap_toggle_hud");
key[KeyType::TOGGLE_CHAT] = getKeySetting("keymap_toggle_chat");
key[KeyType::TOGGLE_FOG] = getKeySetting("keymap_toggle_fog");
diff --git a/src/client/keys.h b/src/client/keys.h
index 9f90da6b8..e120a2d92 100644
--- a/src/client/keys.h
+++ b/src/client/keys.h
@@ -59,6 +59,7 @@ public:
DEC_VOLUME,
CINEMATIC,
SCREENSHOT,
+ TOGGLE_BLOCK_BOUNDS,
TOGGLE_HUD,
TOGGLE_CHAT,
TOGGLE_FOG,
diff --git a/src/client/render/core.cpp b/src/client/render/core.cpp
index 92a7137ea..3c4583623 100644
--- a/src/client/render/core.cpp
+++ b/src/client/render/core.cpp
@@ -76,6 +76,7 @@ void RenderingCore::draw3D()
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
if (!show_hud)
return;
+ hud->drawBlockBounds();
hud->drawSelectionMesh();
if (draw_wield_tool)
camera->drawWieldedTool();