diff options
| author | untodesu <kirill@untode.su> | 2025-03-16 20:18:16 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-03-16 20:18:16 +0500 |
| commit | a8fa9fe920d4ed48ed1b88a6e585cdbff648039e (patch) | |
| tree | 63520fe106ff2e445fa93d2992d14d4f7e60b8e5 /game/shared/dimension.cc | |
| parent | 933ed978a21d5ffefc376d66f0dc9f5354292ca7 (diff) | |
| download | voxelius-a8fa9fe920d4ed48ed1b88a6e585cdbff648039e.tar.bz2 voxelius-a8fa9fe920d4ed48ed1b88a6e585cdbff648039e.zip | |
Improved terrain generation - features! [1/2]
- @reglnk asked me to commit this early to experiment with this
weird-ass heightmap bug that messes with tree placement
Diffstat (limited to 'game/shared/dimension.cc')
| -rw-r--r-- | game/shared/dimension.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/game/shared/dimension.cc b/game/shared/dimension.cc index 378779c..2377214 100644 --- a/game/shared/dimension.cc +++ b/game/shared/dimension.cc @@ -13,7 +13,7 @@ Dimension::Dimension(const char *name, float gravity) Dimension::~Dimension(void) { - for(const auto it : m_hashmap) + for(const auto it : m_chunkmap) delete it.second; entities.clear(); chunks.clear(); @@ -31,9 +31,9 @@ float Dimension::get_gravity(void) const Chunk *Dimension::create_chunk(const chunk_pos &cpos) { - auto it = m_hashmap.find(cpos); + auto it = m_chunkmap.find(cpos); - if(it != m_hashmap.cend()) { + if(it != m_chunkmap.cend()) { // Chunk already exists return it->second; } @@ -52,7 +52,7 @@ Chunk *Dimension::create_chunk(const chunk_pos &cpos) globals::dispatcher.trigger(event); - return m_hashmap.insert_or_assign(cpos, std::move(chunk)).first->second; + return m_chunkmap.insert_or_assign(cpos, std::move(chunk)).first->second; } Chunk *Dimension::find_chunk(entt::entity entity) const @@ -64,8 +64,8 @@ Chunk *Dimension::find_chunk(entt::entity entity) const Chunk *Dimension::find_chunk(const chunk_pos &cpos) const { - auto it = m_hashmap.find(cpos); - if(it != m_hashmap.cend()) + auto it = m_chunkmap.find(cpos); + if(it != m_chunkmap.cend()) return it->second; return nullptr; } @@ -74,18 +74,18 @@ void Dimension::remove_chunk(entt::entity entity) { if(chunks.valid(entity)) { auto &component = chunks.get<ChunkComponent>(entity); - m_hashmap.erase(component.cpos); + m_chunkmap.erase(component.cpos); chunks.destroy(entity); } } void Dimension::remove_chunk(const chunk_pos &cpos) { - auto it = m_hashmap.find(cpos); + auto it = m_chunkmap.find(cpos); - if(it != m_hashmap.cend()) { + if(it != m_chunkmap.cend()) { chunks.destroy(it->second->get_entity()); - m_hashmap.erase(it); + m_chunkmap.erase(it); } } @@ -93,7 +93,7 @@ void Dimension::remove_chunk(Chunk *chunk) { if(chunk) { const auto &component = chunks.get<ChunkComponent>(chunk->get_entity()); - m_hashmap.erase(component.cpos); + m_chunkmap.erase(component.cpos); chunks.destroy(chunk->get_entity()); } } |
