Skip to content

Commit

Permalink
[DebugOverlay] Added chunk updates per sec.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Jul 6, 2020
1 parent d51e4b3 commit 5a98a1d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/client/hud/DebugOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ void DebugOverlay::update() {
stream << "Loaded chunks: " << m_world.loadedChunkCount();
stream << '\n';
stream << "Alive entities: " << m_world.scene().registry().alive();
stream << '\n';
stream << "Chunk updates: " << ClientChunk::chunkUpdatesPerSec;

m_positionText.setString(stream.str());
}
Expand Down
13 changes: 13 additions & 0 deletions source/client/world/ClientChunk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,25 @@
#include "ClientChunk.hpp"
#include "TextureAtlas.hpp"

u32 ClientChunk::chunkUpdatesPerSec = 0;
u32 ClientChunk::chunkUpdateCounter = 0;
u64 ClientChunk::chunkUpdateTime = 0;

void ClientChunk::update() {
u64 time = std::time(nullptr);
if (time > ClientChunk::chunkUpdateTime) {
ClientChunk::chunkUpdatesPerSec = ClientChunk::chunkUpdateCounter;
ClientChunk::chunkUpdateCounter = 0;
ClientChunk::chunkUpdateTime = time;
}

if (m_lightmap.updateLights() || m_hasChanged || m_hasLightChanged) {
m_hasChanged = false;
m_hasLightChanged = false;

m_verticesCount = m_builder.buildChunk(*this, m_vbo);

++ClientChunk::chunkUpdateCounter;
}
}

Expand Down
4 changes: 4 additions & 0 deletions source/client/world/ClientChunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class ClientChunk : public Chunk {

bool areAllNeighboursTooFar() const;

static u32 chunkUpdatesPerSec;
static u32 chunkUpdateCounter;
static u64 chunkUpdateTime;

private:
const Dimension &m_dimension;

Expand Down

0 comments on commit 5a98a1d

Please sign in to comment.