[ClientWorld] Now removes far uninitialized chunks.

This commit is contained in:
Quentin Bazin 2021-05-17 21:29:52 +02:00
parent e84cf25fdb
commit 1ea2c350e4
2 changed files with 11 additions and 17 deletions

View File

@ -54,22 +54,10 @@ void ClientWorld::update(bool allowWorldReload) {
ClientChunk::chunkUpdateTime = time; ClientChunk::chunkUpdateTime = time;
} }
// FIXME for (auto it = m_chunksToRemove.begin() ; it != m_chunksToRemove.end() ;) {
// Update loaded chunks removeChunk(*it);
// std::list<gk::Vector3i> chunksToRemove; it = m_chunksToRemove.erase(it);
// for (auto &it : m_chunks) { }
// if (World::isReloadRequested && allowWorldReload)
// it.second->setChanged(true);
//
// if (it.second->isReadyForMeshing())
// it.second->update();
//
// if (it.second->isTooFar() && !it.second->isInitialized())
// chunksToRemove.emplace_back(gk::Vector3i{it.second->x(), it.second->y(), it.second->z()});
// }
//
// for (auto &it : chunksToRemove)
// removeChunk(it);
if (allowWorldReload) { if (allowWorldReload) {
if (World::isReloadRequested) { if (World::isReloadRequested) {
@ -317,9 +305,13 @@ void ClientWorld::draw(gk::RenderTarget &target, gk::RenderStates states) const
// Nope, too far, don't render it // Nope, too far, don't render it
if(glm::length(center) > (Config::renderDistance + 1) * CHUNK_WIDTH) { if(glm::length(center) > (Config::renderDistance + 1) * CHUNK_WIDTH) {
if(floor(glm::length(center)) > (Config::renderDistance + 3) * CHUNK_WIDTH) if(floor(glm::length(center)) > (Config::renderDistance + 2) * CHUNK_WIDTH) {
it.second->setTooFar(true); it.second->setTooFar(true);
if (!it.second->isInitialized())
m_chunksToRemove.emplace(gk::Vector3i{it.second->x(), it.second->y(), it.second->z()});
}
continue; continue;
} }

View File

@ -95,6 +95,8 @@ class ClientWorld : public World, public gk::Drawable {
mutable gk::Vector4d m_closestInitializedChunk{0, 0, 0, 1000000}; mutable gk::Vector4d m_closestInitializedChunk{0, 0, 0, 1000000};
const Sky *m_sky = nullptr; const Sky *m_sky = nullptr;
mutable std::set<gk::Vector3i> m_chunksToRemove;
}; };
#endif // CLIENTWORLD_HPP_ #endif // CLIENTWORLD_HPP_