summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-10 00:14:47 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-10 00:16:43 +0200
commit2b9e97e28ed0504de15d73ff5e1dd0ff9deb6d09 (patch)
treeeee807781ce6584eaa16ebe254e27016d7422fa1 /src
parent3212ca62361da55e8eec4cb97ee1698b534daad6 (diff)
src/world: pre-initialize entity ctr to 1024
This way, rtree object_id can only be equal to entity's id if it's an entity and not static geometry.
Diffstat (limited to 'src')
-rw-r--r--src/world.hpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/world.hpp b/src/world.hpp
index 8148bfd5..4b8ce797 100644
--- a/src/world.hpp
+++ b/src/world.hpp
@@ -19,6 +19,10 @@ template<typename T> struct entity_type_;
struct world final
{
+ static constexpr object_id entity_counter_init = 1024;
+ static constexpr size_t initial_capacity = 64;
+ static constexpr float max_load_factor = .5;
+
private:
struct chunk_tuple final {
static constexpr chunk_coords_ invalid_coords = { -1 << 15, -1 << 15, chunk_min_z };
@@ -26,14 +30,12 @@ private:
chunk_coords_ pos = invalid_coords;
} _last_chunk;
- static constexpr size_t initial_capacity = 64;
- static constexpr float max_load_factor = .5;
std::unordered_map<chunk_coords_, chunk> _chunks;
std::unordered_map<object_id, std::weak_ptr<entity>> _entities;
size_t _last_collection = 0;
size_t _collect_every = 64;
std::shared_ptr<char> _unique_id = std::make_shared<char>('A');
- object_id _entity_counter = 0;
+ object_id _entity_counter = entity_counter_init;
uint64_t _current_frame = 1; // zero is special for struct entity
bool _teardown : 1 = false;