diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-09 11:45:34 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-09 11:45:34 +0100 |
commit | ff3a18b1a251a5e85057e52303efa0cdd79e8a66 (patch) | |
tree | 44c2f3a6f69bc922d71063debd14ba669c74ca0d /src/world.hpp | |
parent | b4770eb85369e91cbf800e8192dac0d8c0c627cf (diff) |
add floor mesh to struct chunk
Diffstat (limited to 'src/world.hpp')
-rw-r--r-- | src/world.hpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/world.hpp b/src/world.hpp index 195d4903..248f9dc4 100644 --- a/src/world.hpp +++ b/src/world.hpp @@ -11,23 +11,28 @@ namespace floormat { struct world final { private: + struct chunk_tuple final { + static constexpr chunk_coords invalid_coords = { -1 << 15, -1 << 15 }; + chunk* c = nullptr; + chunk_coords pos = invalid_coords; + } _last_chunk; + void maybe_collect(); - static constexpr std::size_t initial_capacity = 64, collect_every = 32; + 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 { return int_hash((std::size_t)c.y << 16 | (std::size_t)c.x); }; - std::unordered_map<chunk_coords, chunk, decltype(hasher)> _chunks; - mutable std::tuple<chunk*, chunk_coords> _last_chunk; std::size_t _last_collection = 0; + explicit world(std::size_t capacity); public: explicit world(); - struct pair final { chunk& c; tile_ref t; }; + struct pair final { chunk& c; tile_ref t; }; // NOLINT template<typename Hash, typename Alloc, typename Pred> explicit world(std::unordered_map<chunk_coords, chunk, Hash, Alloc, Pred>&& chunks); |