Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubpa committed Mar 23, 2021
1 parent 653d6ab commit 1148ac1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 5 additions & 1 deletion include/UECS/Chunk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ namespace Ubpa::UECS {

// if not contains the component, return nullptr
template<typename Cmpt>
std::span<Cmpt> GetCmptArray() const noexcept { return { (Cmpt*)GetCmptArray(TypeID_of<Cmpt>), GetHead()->num_component }; }
std::span<Cmpt> GetCmptArray() const noexcept {
void* ptr = GetCmptArray(TypeID_of<Cmpt>);
if (ptr) return { (Cmpt*)ptr,EntityNum() };
else return {};
}

std::span<Entity> GetEntityArray() const noexcept { return GetCmptArray<Entity>(); }

Expand Down
11 changes: 6 additions & 5 deletions src/core/World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ World::~World() {
}

void World::Update() {
// 1. clear
schedule.Clear();

sync_frame_rsrc->release();
unsync_frame_rsrc->release();

entityMngr.NewFrame();

// 2. update schedule
Expand Down Expand Up @@ -102,11 +108,6 @@ void World::Update() {

// 4. update version
version++;

schedule.Clear();

sync_frame_rsrc->release();
unsync_frame_rsrc->release();
}

string World::DumpUpdateJobGraph() const {
Expand Down
2 changes: 1 addition & 1 deletion src/test/24_rsrc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ int main() {
w.systemMngr.RegisterAndCreate<FillSystem>();
w.systemMngr.Activate<FillSystem>();

for (std::size_t i = 0; i < 100000; i++)
for (std::size_t i = 0; i < 10000; i++)
w.entityMngr.Create(TypeIDs_of<Buffer>);

w.Update();
Expand Down

0 comments on commit 1148ac1

Please sign in to comment.