summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--editor/update.cpp2
-rw-r--r--src/world.cpp1
-rw-r--r--src/world.hpp3
3 files changed, 3 insertions, 3 deletions
diff --git a/editor/update.cpp b/editor/update.cpp
index 3481ea3b..115e58b9 100644
--- a/editor/update.cpp
+++ b/editor/update.cpp
@@ -184,6 +184,8 @@ void app::update(float dt)
else
set_cursor_from_imgui();
}
+
+ M->world().maybe_collect();
}
} // namespace floormat
diff --git a/src/world.cpp b/src/world.cpp
index a95cdd21..20805905 100644
--- a/src/world.cpp
+++ b/src/world.cpp
@@ -14,7 +14,6 @@ world::world(std::size_t capacity) : _chunks{capacity, hasher}
chunk& world::operator[](chunk_coords coord) noexcept
{
- maybe_collect();
auto& [c, coord2] = _last_chunk;
if (coord != coord2)
c = &_chunks.try_emplace(coord).first->second;
diff --git a/src/world.hpp b/src/world.hpp
index b95baf62..3bfcf702 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -18,8 +18,6 @@ private:
chunk_coords pos = invalid_coords;
} _last_chunk;
- void maybe_collect();
-
static constexpr std::size_t initial_capacity = 64, collect_every = 64;
static constexpr float max_load_factor = .5;
static constexpr auto hasher = [](chunk_coords c) constexpr -> std::size_t {
@@ -43,6 +41,7 @@ public:
bool contains(chunk_coords c) const noexcept;
void clear();
void collect(bool force = false);
+ void maybe_collect();
std::size_t size() const noexcept { return _chunks.size(); }
[[deprecated]] const auto& chunks() const noexcept { return _chunks; } // only for serialization