From b98fa1c29ae693a39cf6b8f4a06877bf6410e08c Mon Sep 17 00:00:00 2001 From: ubpa Date: Sat, 15 May 2021 00:08:12 +0800 Subject: [PATCH] fix a bug --- CMakeLists.txt | 2 +- src/core/Archetype.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3aaf179..9ca921f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR) -project(UECS VERSION 0.16.0) +project(UECS VERSION 0.16.1) message(STATUS "[Project] ${PROJECT_NAME}") include(cmake/InitUCMake.cmake) diff --git a/src/core/Archetype.cpp b/src/core/Archetype.cpp index d204d53..658db6c 100644 --- a/src/core/Archetype.cpp +++ b/src/core/Archetype.cpp @@ -300,11 +300,11 @@ std::size_t Archetype::Erase(EntityAddress addr) { entityNum--; - if (chunk->Empty()) { - nonFullChunks.erase(addr.chunkIdx); - chunk->~Chunk(); - world->GetUnsyncResource()->deallocate(chunk, sizeof(Chunk), alignof(Chunk)); - chunks.erase(std::find(chunks.begin(), chunks.end(), chunk)); + while (!chunks.empty() && chunks.back()->Empty()) { + nonFullChunks.erase(chunks.size() - 1); + chunks.back()->~Chunk(); + world->GetUnsyncResource()->deallocate(chunks.back(), sizeof(Chunk), alignof(Chunk)); + chunks.pop_back(); } return movedEntityIdx;