From 92fa009e9d85769d2754643fdb14406523f55372 Mon Sep 17 00:00:00 2001 From: Quentin Bazin Date: Thu, 2 Jul 2020 16:40:20 +0200 Subject: [PATCH] [DebugOverlay] Fixed relative position. --- source/client/hud/DebugOverlay.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/client/hud/DebugOverlay.cpp b/source/client/hud/DebugOverlay.cpp index 874b9fac9..b1b50b633 100644 --- a/source/client/hud/DebugOverlay.cpp +++ b/source/client/hud/DebugOverlay.cpp @@ -56,6 +56,14 @@ void DebugOverlay::update() { s32 py = std::floor(m_player.y()); s32 pz = std::floor(m_player.z()); + s32 rx = px % CHUNK_WIDTH; + s32 ry = py % CHUNK_DEPTH; + s32 rz = pz % CHUNK_HEIGHT; + + if (rx < 0) rx += 16; + if (ry < 0) ry += 16; + if (rz < 0) rz += 16; + // Directions is now an angle4 const char *directions[4] = {"East", "North", "West", "South"}; const char *direction = directions[m_player.getDirection()]; @@ -65,9 +73,9 @@ void DebugOverlay::update() { stream << "y: " << py << " | "; stream << "z: " << pz; stream << '\n'; - stream << "rx: " << px % CHUNK_WIDTH << " | "; - stream << "ry: " << py % CHUNK_DEPTH << " | "; - stream << "rz: " << pz % CHUNK_HEIGHT; + stream << "rx: " << rx << " | "; + stream << "ry: " << ry << " | "; + stream << "rz: " << rz; stream << '\n'; stream << "cx: " << (px & -CHUNK_WIDTH) / CHUNK_WIDTH << " | "; stream << "cy: " << (py & -CHUNK_DEPTH) / CHUNK_DEPTH << " | ";