diff --git a/.idea/misc.xml b/.idea/misc.xml
index fa3f5e2d..2ce47f5b 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -6,6 +6,10 @@
+
+
+
+
diff --git a/src/client/gui/DebugGui.cpp b/src/client/gui/DebugGui.cpp
index b1ffc1f1..bc3586a4 100644
--- a/src/client/gui/DebugGui.cpp
+++ b/src/client/gui/DebugGui.cpp
@@ -61,7 +61,7 @@ DebugGui::DebugGui(u16vec2 buffer, SubgamePtr game, LocalWorld& world, vec("chunkStates");
- chunkStates->create(6, vec4(4), CHUNK_RANGE, "Chunk Compression", f);
+ chunkStates->create(12, vec4(4), MAPBLOCK_RANGE, "Mapblocks", f);
chunkStates->refresh();
add(chunkStates);
@@ -82,7 +82,7 @@ void DebugGui::positionElements(u16vec2 buffer) {
get("gpuGraph")->setPos({ buffer.x - 254, 90 + 80 });
get("perfGraph")->setPos({ buffer.x - 354 - 254, 10 });
- get("chunkStates")->setPos({ buffer.x - 264 - 300, buffer.y - 334 });
+ get("chunkStates")->setPos({ buffer.x - 264 - 144, buffer.y - 178 });
}
void DebugGui::update(sptr player, f64 delta, u32 interpolatedChunks, u32 generatedChunks,
@@ -176,51 +176,40 @@ void DebugGui::update(sptr player, f64 delta, u32 interpolatedChunk
str << "No Target" << std::endl << std::endl;
}
-// for (usize i = 0; i < perfTimings.size(); i++) {
-// str << perfSections[i] << ": " << perfTimings[i] << " ns." << std::endl;
-// }
-
get("dataText")->setText(str.str());
// Chunk States
- if (chunkTimer == 0) {
- auto chunkStates = get("chunkStates");
- ivec3 off = { 0, 0, 0 };
- for (off.x = 0; off.x < CHUNK_RANGE; off.x++) {
- for (off.z = 0; off.z < CHUNK_RANGE; off.z++) {
- f32 existAmount = 0;
- f32 compressedAmount = 0;
- ivec3 check = ivec3(chunkPos) + off -
- glm::ivec3(floor(CHUNK_RANGE / 2), 0, floor(CHUNK_RANGE / 2));
+ auto chunkStates = get("chunkStates");
+ ivec3 off = { 0, 0, 0 };
+ for (off.x = 0; off.x < MAPBLOCK_RANGE; off.x++) {
+ if ((off.x - mapBlockScanX) % MAPBLOCK_SCAN_X_INTERVAL != 0) continue;
+
+ for (off.z = 0; off.z < MAPBLOCK_RANGE; off.z++) {
+ f32 existAmount = 0;
+ ivec3 check = ivec3(mapBlockPos) + off -
+ ivec3(MAPBLOCK_RANGE / 2, 0, MAPBLOCK_RANGE / 2);
- for (off.y = 0; off.y < CHUNK_VERT; off.y++) {
- check.y = static_cast(chunkPos.y) + off.y - CHUNK_VERT / 2;
- const auto chunk = world.getActiveDimension()->getChunk(check);
- if (chunk) {
- existAmount++;
- if (chunk->isCompressed()) compressedAmount++;
- }
- }
-
- const auto color = glm::mix(CHUNK_UNLOADED,
- glm::mix(CHUNK_UNCOMPRESSED, CHUNK_COMPRESSED,
- compressedAmount / CHUNK_VERT),existAmount / CHUNK_VERT);
-
- chunkStates->setCellColor(u16vec2(off.x, off.z), color);
+ for (off.y = 0; off.y < MAPBLOCK_VERT; off.y++) {
+ check.y = static_cast(chunkPos.y) + off.y - MAPBLOCK_VERT / 2;
+ const auto mapBlock = world.getActiveDimension()->getMapBlock(check);
+ if (mapBlock) existAmount++;
}
- }
- chunkStates->refresh();
- }
-
- chunkTimer = (chunkTimer + 1) % CHUNK_INTERVAL;
- // Crosshair information
+ const auto color =
+ (off.x == MAPBLOCK_RANGE / 2 && off.z == MAPBLOCK_RANGE / 2) ? MAPBLOCK_CURRENT
+ : glm::mix(MAPBLOCK_UNLOADED, MAPBLOCK_LOADED, existAmount / MAPBLOCK_VERT);
+ chunkStates->setCellColor(u16vec2(off.x, off.z), color);
+ }
+ }
+ chunkStates->refresh();
+
+ mapBlockScanX = (mapBlockScanX + 1) % MAPBLOCK_SCAN_X_INTERVAL;
if (target.type == Target::Type::BLOCK) {
const auto& def = game->getDefs().blockFromId(world.getActiveDimension()->getBlock(target.data.block.pos));
- get("crosshairText")->setText(
- "`b" + def.name + " (`r` `c7" + def.identifier + "`cr - " + std::to_string(def.index) + "` `b)");
+ get("crosshairText")->setText("`b" + def.name + " (`r` `c7" +
+ def.identifier + "`cr - " + std::to_string(def.index) + "` `b)");
}
else {
get("crosshairText")->setText("");
diff --git a/src/client/gui/DebugGui.h b/src/client/gui/DebugGui.h
index 9a0c0c9e..0adfc694 100644
--- a/src/client/gui/DebugGui.h
+++ b/src/client/gui/DebugGui.h
@@ -37,18 +37,18 @@ public:
private:
- constexpr static vec4 CHUNK_UNLOADED = { 1, 1, 1, 0.15 };
- constexpr static vec4 CHUNK_COMPRESSED = { 1, 1, 1, 0.75 };
- constexpr static vec4 CHUNK_UNCOMPRESSED = { 1, 0, 0, 0.75 };
+ constexpr static vec4 MAPBLOCK_UNLOADED = { 1, 1, 1, 0.15 };
+ constexpr static vec4 MAPBLOCK_LOADED = { 1, 1, 1, 0.75 };
+ constexpr static vec4 MAPBLOCK_CURRENT = { 1, 0.93, 0.35, 1 };
- constexpr static i32 CHUNK_VERT = 3;
- constexpr static i32 CHUNK_RANGE = 48;
+ constexpr static i32 MAPBLOCK_VERT = 3;
+ constexpr static i32 MAPBLOCK_RANGE = 11;
+
+ u32 mapBlockScanX = 0;
+ constexpr static u32 MAPBLOCK_SCAN_X_INTERVAL = 9;
SubgamePtr game;
LocalWorld& world;
- u16 chunkTimer = 0;
- constexpr static u16 CHUNK_INTERVAL = 5;
-
Visibility state = Visibility::ON;
};
diff --git a/src/client/gui/basic/GuiMeter.cpp b/src/client/gui/basic/GuiMeter.cpp
index 371dcf2e..98e37753 100644
--- a/src/client/gui/basic/GuiMeter.cpp
+++ b/src/client/gui/basic/GuiMeter.cpp
@@ -84,14 +84,15 @@ void GuiMeter::updateMesh() {
}
const vec GuiMeter::COLORS = {
- { 63 / 255.f, 224 / 255.f, 208 / 255.f },
- { 51 / 255.f, 187 / 255.f, 232 / 255.f },
- { 94 / 255.f, 105 / 255.f, 219 / 255.f },
- { 159 / 255.f, 94 / 255.f, 255 / 255.f },
- { 255 / 255.f, 138 / 255.f, 243 / 255.f },
- { 255 / 255.f, 102 / 255.f, 102 / 255.f },
- { 255 / 255.f, 157 / 255.f, 77 / 255.f },
- { 169 / 255.f, 212 / 255.f, 89 / 255.f },
- { 42 / 255.f, 212 / 255.f, 119 / 255.f },
- { 0.3, 0.3, 0.3 }
+ vec3 { 63, 224, 208 } / 255.f,
+ vec3 { 51, 187, 232 } / 255.f,
+ vec3 { 94, 105, 219 } / 255.f,
+ vec3 { 159, 94, 255 } / 255.f,
+ vec3 { 255, 138, 243 } / 255.f,
+ vec3 { 255, 102, 102 } / 255.f,
+// vec3 { 255, 157, 77 } / 255.f,
+// vec3 { 169, 212, 89 } / 255.f,
+// vec3 { 42, 212, 119 } / 255.f,
+ vec3 { 200, 200, 200 } / 255.f,
+ vec3 { 120, 120, 120 } / 255.f
};
\ No newline at end of file
diff --git a/src/client/gui/compound/GuiPerfGraph.cpp b/src/client/gui/compound/GuiPerfGraph.cpp
index 0c6b957e..5c84de1c 100644
--- a/src/client/gui/compound/GuiPerfGraph.cpp
+++ b/src/client/gui/compound/GuiPerfGraph.cpp
@@ -24,7 +24,7 @@ void GuiPerfGraph::create(f32 scale, vec4 padding, const vec& sections,
background->setPos({ 0, 0 });
auto meter = make_shared("meter");
- meter->create({ scale - GRAPH_PAD_X * 2, 24 }, {}, 0.85);
+ meter->create({ scale - GRAPH_PAD_X * 2, 24 }, {}, 0.95);
add(meter);
meter->setBudget(1 / 60.f * 1000000000);
meter->setPos({ GRAPH_PAD_X, GRAPH_PAD_Y });
diff --git a/src/client/scene/GameScene.cpp b/src/client/scene/GameScene.cpp
index 02f56659..f2988501 100644
--- a/src/client/scene/GameScene.cpp
+++ b/src/client/scene/GameScene.cpp
@@ -25,7 +25,7 @@ void GameScene::update() {
Window& window = client.renderer.window;
auto perfTimings = perf.end();
- perf.start("update:mods");
+ perf.start("other");
client.game->update(client.getDelta());
world.l()->update(client.getDelta(), perfTimings, perf);
diff --git a/src/client/scene/GameScene.h b/src/client/scene/GameScene.h
index 8085377c..b065b9d2 100644
--- a/src/client/scene/GameScene.h
+++ b/src/client/scene/GameScene.h
@@ -18,8 +18,8 @@ public:
void draw() override;
private:
- vec perfSections = { "update:mods", "update:world", "update:player", "update:net", "update:chunks",
- "draw:world", "draw:entities", "draw:interface", "update:debug", "idle" };
+ vec perfSections = { "update:world", "update:player", "update:debug",
+ "draw:world", "draw:entities", "draw:interface", "other", "idle" };
PerfTimer perf { perfSections };
WorldPtr world;
diff --git a/src/util/PerfTimer.cpp b/src/util/PerfTimer.cpp
index 1487c099..c9306c6c 100644
--- a/src/util/PerfTimer.cpp
+++ b/src/util/PerfTimer.cpp
@@ -8,6 +8,15 @@ void PerfTimer::start(const string& section) {
stopCurrent();
const usize ind = find(sections.begin(), sections.end(), section) - sections.begin();
if (ind == sections.size()) throw std::invalid_argument("Tried to start invalid section '" + section + "'");
+ timings[ind] = 0;
+ timer = Timer();
+ currentSection = section;
+}
+
+void PerfTimer::resume(const string& section) {
+ stopCurrent();
+ const usize ind = find(sections.begin(), sections.end(), section) - sections.begin();
+ if (ind == sections.size()) throw std::invalid_argument("Tried to resume invalid section '" + section + "'");
timer = Timer();
currentSection = section;
}
@@ -22,7 +31,7 @@ vec PerfTimer::end() {
void PerfTimer::stopCurrent() {
if (currentSection != "") {
const usize ind = find(sections.begin(), sections.end(), currentSection) - sections.begin();
- timings[ind] = timer.elapsedNs();
+ timings[ind] += timer.elapsedNs();
currentSection = "";
}
}
diff --git a/src/util/PerfTimer.h b/src/util/PerfTimer.h
index d2d485c6..14216a69 100644
--- a/src/util/PerfTimer.h
+++ b/src/util/PerfTimer.h
@@ -7,6 +7,8 @@ public:
PerfTimer(const vec& sections);
void start(const string& section);
+ void resume(const string& section);
+
vec end();
private:
void stopCurrent();
diff --git a/src/world/LocalWorld.cpp b/src/world/LocalWorld.cpp
index f904f4c0..a33aa191 100644
--- a/src/world/LocalWorld.cpp
+++ b/src/world/LocalWorld.cpp
@@ -16,7 +16,7 @@ LocalWorld::LocalWorld(SubgamePtr game, ServerConnection& conn, Renderer& render
// worldGenStream(make_shared(*game.l(), *this, 55)),
player(make_shared(game, *this, DimensionPtr(nullptr), renderer)) {
- renderer.window.onResize(Util::bind_this(&debugGui, &DebugGui::bufferResized));
+ lock = renderer.window.onResize(Util::bind_this(&debugGui, &DebugGui::bufferResized));
}
void LocalWorld::init() {
@@ -43,15 +43,9 @@ void LocalWorld::update(f64 delta, vec& perfTimings, PerfTimer& perf) {
refs->update(delta, net);
// Update the network
- perf.start("update:net");
+ perf.resume("other");
net.update();
- // Commit interpolated mapblocks
- perf.start("update:chunks");
-// auto finishedChunks = worldGenStream->update();
-// lastInterpolations = finishedChunks->size() / 64;
-// for (const auto& chunk : *finishedChunks) commitChunk(chunk);
-
// Update debug interface
perf.start("update:debug");
debugGui.update(
@@ -60,20 +54,21 @@ void LocalWorld::update(f64 delta, vec& perfTimings, PerfTimer& perf) {
perfTimings,
activeDimension->getMeshChunksDrawn(),
activeDimension->getMeshChunksCommitted());
+ perf.resume("other");
// Toggle regular interface
if (renderer.window.input.keyPressed(GLFW_KEY_F1)) {
hudVisible = !hudVisible;
- debugGui.changeVisibility(hudVisible ? debugVisible ? DebugGui::Visibility::OFF :
- DebugGui::Visibility::FPS_ONLY : DebugGui::Visibility::ON);
player.l()->setHudVisible(hudVisible);
+ debugGui.changeVisibility(hudVisible ? debugVisible ? DebugGui::Visibility::ON :
+ DebugGui::Visibility::FPS_ONLY : DebugGui::Visibility::OFF);
}
// Toggle debug interface
if (renderer.window.input.keyPressed(GLFW_KEY_F3)) {
debugVisible = !debugVisible;
- debugGui.changeVisibility(hudVisible ? debugVisible ? DebugGui::Visibility::OFF :
- DebugGui::Visibility::FPS_ONLY : DebugGui::Visibility::ON);
+ debugGui.changeVisibility(hudVisible ? debugVisible ? DebugGui::Visibility::ON :
+ DebugGui::Visibility::FPS_ONLY : DebugGui::Visibility::OFF);
}
}
diff --git a/src/world/dim/LocalDimension.cpp b/src/world/dim/LocalDimension.cpp
index a8d50295..ad35d8a6 100644
--- a/src/world/dim/LocalDimension.cpp
+++ b/src/world/dim/LocalDimension.cpp
@@ -52,7 +52,7 @@ void LocalDimension::update(f64 delta) {
for (let it = regions.cbegin(); it != regions.cend();) {
for (u16 m = 0; m < 64; m++) {
let mapBlock = it->second->get(m);
- if (!mapBlock) continue;
+ if (!mapBlock || (mapBlock->pos.y - mapBlockScanY) % MAPBLOCK_SCAN_Y_INTERVAL != 0) continue;
if (abs(clientMapBlock.x - mapBlock->pos.x) > retainMapBlockRange.x ||
abs(clientMapBlock.y - mapBlock->pos.y) > retainMapBlockRange.y ||
@@ -80,6 +80,8 @@ void LocalDimension::update(f64 delta) {
erase_region_and_continue:
it = regions.erase(it);
}
+
+ mapBlockScanY = (mapBlockScanY + 1) % MAPBLOCK_SCAN_Y_INTERVAL;
}
void LocalDimension::setChunk(sptr chunk) {
diff --git a/src/world/dim/LocalDimension.h b/src/world/dim/LocalDimension.h
index e3e05edb..2f4f0cbc 100644
--- a/src/world/dim/LocalDimension.h
+++ b/src/world/dim/LocalDimension.h
@@ -98,6 +98,9 @@ private:
std::unordered_map renderRefs{};
std::list> renderElems{};
+ u32 mapBlockScanY = 0;
+ const static u32 MAPBLOCK_SCAN_Y_INTERVAL = 8;
+
const ivec2 retainMapBlockRange = { 4, 4 };
i64 entityInd = -1;
};