Compare commits
2 commits
cb05c2cf1d
...
72f635400a
Author | SHA1 | Date | |
---|---|---|---|
72f635400a | |||
bcd5a8135d |
2 changed files with 39 additions and 4 deletions
|
@ -473,12 +473,40 @@ TEST_CASE("Archetype signature management")
|
||||||
// Initial state: empty archetype
|
// Initial state: empty archetype
|
||||||
REQUIRE(w.archetype_count() == 0);
|
REQUIRE(w.archetype_count() == 0);
|
||||||
|
|
||||||
auto e = w.make_entity();
|
auto e0 = w.make_entity();
|
||||||
REQUIRE(w.archetype_count() == 1);
|
REQUIRE(w.archetype_count() == 1); //<>
|
||||||
|
|
||||||
// Add first component
|
// Add first component
|
||||||
w.set<A>(e);
|
w.set<A>(e0);
|
||||||
REQUIRE(w.archetype_count() == 1);
|
REQUIRE(w.archetype_count() == 1); //<A>
|
||||||
|
|
||||||
|
w.set<B>(e0);
|
||||||
|
REQUIRE(w.archetype_count() == 1); //<A, B>
|
||||||
|
|
||||||
|
w.set<C>(e0);
|
||||||
|
REQUIRE(w.archetype_count() == 1); //<A, B, C>
|
||||||
|
|
||||||
|
w.remove<A, B>(e0);
|
||||||
|
REQUIRE(w.archetype_count() == 1); //<C>
|
||||||
|
|
||||||
|
auto e1 = w.make_entity();
|
||||||
|
w.set<A, B>(e1);
|
||||||
|
REQUIRE(w.archetype_count() == 2); //<C>, <A, B>
|
||||||
|
|
||||||
|
w.remove<C>(e0);
|
||||||
|
REQUIRE(w.archetype_count() == 2); //<>, <A, B>
|
||||||
|
|
||||||
|
w.set<A>(e0);
|
||||||
|
REQUIRE(w.archetype_count() == 2); //<A>, <A, B>
|
||||||
|
|
||||||
|
w.set<B>(e0);
|
||||||
|
REQUIRE(w.archetype_count() == 1); //<A, B>
|
||||||
|
|
||||||
|
w.destroy_entity(e0);
|
||||||
|
REQUIRE(w.archetype_count() == 1); //<A, B>
|
||||||
|
|
||||||
|
w.destroy_entity(e1);
|
||||||
|
REQUIRE(w.archetype_count() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Component distribution across archetypes")
|
TEST_CASE("Component distribution across archetypes")
|
||||||
|
@ -499,11 +527,13 @@ TEST_CASE("Component distribution across archetypes")
|
||||||
auto e = w.make_entity();
|
auto e = w.make_entity();
|
||||||
w.set<A>(e);
|
w.set<A>(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 3; ++i)
|
for(int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
auto e = w.make_entity();
|
auto e = w.make_entity();
|
||||||
w.set<A, B>(e);
|
w.set<A, B>(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 2; ++i)
|
for(int i = 0; i < 2; ++i)
|
||||||
{
|
{
|
||||||
auto e = w.make_entity();
|
auto e = w.make_entity();
|
||||||
|
|
|
@ -319,6 +319,11 @@ namespace zecsy
|
||||||
|
|
||||||
archetypes[new_key].emplace_back(e);
|
archetypes[new_key].emplace_back(e);
|
||||||
|
|
||||||
|
if(archetypes[old_key].empty())
|
||||||
|
{
|
||||||
|
archetypes.erase(old_key);
|
||||||
|
}
|
||||||
|
|
||||||
auto& pool = pools[id];
|
auto& pool = pools[id];
|
||||||
auto index = pool.entity_to_index[e];
|
auto index = pool.entity_to_index[e];
|
||||||
pool.free_list.push_back(index);
|
pool.free_list.push_back(index);
|
||||||
|
|
Loading…
Reference in a new issue