Skip to content

Commit

Permalink
Fix ECS bugs. #54
Browse files Browse the repository at this point in the history
Move-assign in Archetype::erase assigning in the wrong direction.
foreachEntity iterate over the mEntityToArchetypeID list and check for null entities.
  • Loading branch information
MStachowicz committed Apr 23, 2023
1 parent bfcf9c6 commit 394b00c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions source/ECS/Storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ namespace ECS
const auto eraseInstanceCompStartPosition = eraseInstanceStartPosition + mComponents[comp].offset;
const auto eraseInstanceCompAddress = &m_data[eraseInstanceCompStartPosition];

mComponents[comp].info.funcs.MoveAssign(lastInstanceCompAddress, eraseInstanceCompAddress);
mComponents[comp].info.funcs.MoveAssign(eraseInstanceCompAddress, lastInstanceCompAddress);
mComponents[comp].info.funcs.Destruct(lastInstanceCompAddress);
}

Expand Down Expand Up @@ -769,9 +769,9 @@ namespace ECS
using FunctionParameterPack = typename Meta::GetFunctionInformation<Func>::GetParameterPack;
static_assert(FunctionHelper<FunctionParameterPack>::isEntityFunction(), "pFunction is not a function that takes only one argument of type ECS::Entity");

if (mNextEntity > 0)
for (EntityID i = 0; i < mEntityToArchetypeID.size(); i++)
{
for (EntityID i = 0; i < mNextEntity; i++)
if (mEntityToArchetypeID[i].has_value())
{
auto ent = Entity(i);
pFunction(ent);
Expand Down

0 comments on commit 394b00c

Please sign in to comment.