Fixed bug where deleted entities retain info
This commit is contained in:
parent
74ecae5dff
commit
ab2209b698
2 changed files with 36 additions and 3 deletions
|
@ -80,9 +80,6 @@ namespace EC
|
|||
|
||||
std::get<bool>(entities[currentSize]) = true;
|
||||
|
||||
// TODO This shouldn't be necessary, but there is a bug
|
||||
std::get<BitsetType>(entities[currentSize]).reset();
|
||||
|
||||
return currentSize++;
|
||||
}
|
||||
|
||||
|
@ -143,6 +140,7 @@ namespace EC
|
|||
currentSize = 0;
|
||||
return;
|
||||
}
|
||||
std::get<BitsetType>(entities[rhs]).reset();
|
||||
--rhs;
|
||||
}
|
||||
if(lhs >= rhs)
|
||||
|
|
|
@ -207,3 +207,38 @@ TEST(EC, MoveComponentWithUniquePtr)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(EC, DeletedEntities)
|
||||
{
|
||||
EC::Manager<ListComponentsAll, ListTagsAll> manager;
|
||||
|
||||
for(unsigned int i = 0; i < 4; ++i)
|
||||
{
|
||||
auto eid = manager.addEntity();
|
||||
manager.addComponent<C0>(eid);
|
||||
if(i >= 2)
|
||||
{
|
||||
manager.deleteEntity(eid);
|
||||
}
|
||||
}
|
||||
|
||||
manager.cleanup();
|
||||
|
||||
for(unsigned int i = 0; i < 4; ++i)
|
||||
{
|
||||
if(i < 2)
|
||||
{
|
||||
EXPECT_TRUE(manager.hasComponent<C0>(i));
|
||||
}
|
||||
else
|
||||
{
|
||||
EXPECT_FALSE(manager.hasComponent<C0>(i));
|
||||
}
|
||||
}
|
||||
|
||||
for(unsigned int i = 0; i < 2; ++i)
|
||||
{
|
||||
auto eid = manager.addEntity();
|
||||
EXPECT_FALSE(manager.hasComponent<C0>(eid));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue