Skip to content

Commit

Permalink
[DebugOverlay] Fixed relative position.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jul 2, 2020
1 parent ff1d34c commit 92fa009
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions source/client/hud/DebugOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()];
Expand All @@ -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 << " | ";
Expand Down

0 comments on commit 92fa009

Please sign in to comment.