From ff3a18b1a251a5e85057e52303efa0cdd79e8a66 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 9 Nov 2022 11:45:34 +0100 Subject: add floor mesh to struct chunk --- src/world.hpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/world.hpp') 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 _chunks; - mutable std::tuple _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 explicit world(std::unordered_map&& chunks); -- cgit v1.2.3