Bugfix in ecs query caches: store the component UUIDs in vectors instead of hash sets, because the order of components matters
This commit is contained in:
parent
e3750707bc
commit
99ca3ec2eb
1 changed files with 8 additions and 10 deletions
|
|
@ -13,8 +13,8 @@ namespace psemek::ecs::detail
|
|||
struct query_cache_data
|
||||
{
|
||||
std::size_t hash;
|
||||
util::hash_set<util::uuid> with_uuids;
|
||||
util::hash_set<util::uuid> without_uuids;
|
||||
std::vector<util::uuid> with_uuids;
|
||||
std::vector<util::uuid> without_uuids;
|
||||
std::shared_ptr<query_cache> cache;
|
||||
};
|
||||
|
||||
|
|
@ -41,12 +41,10 @@ namespace psemek::ecs::detail
|
|||
if (uuids.second.size() != set->without_uuids.size())
|
||||
return false;
|
||||
|
||||
for (auto const & uuid : uuids.first)
|
||||
if (!set->with_uuids.contains(uuid))
|
||||
if (!std::equal(uuids.first.begin(), uuids.first.end(), set->with_uuids.begin()))
|
||||
return false;
|
||||
|
||||
for (auto const & uuid : uuids.second)
|
||||
if (!set->without_uuids.contains(uuid))
|
||||
if (!std::equal(uuids.second.begin(), uuids.second.end(), set->without_uuids.begin()))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -70,12 +68,12 @@ namespace psemek::ecs::detail
|
|||
value->cache = std::make_shared<query_cache>();
|
||||
for (auto const & uuid : with_uuids)
|
||||
{
|
||||
value->with_uuids.insert(uuid);
|
||||
value->with_uuids.push_back(uuid);
|
||||
value->cache->with_uuids.push_back(uuid);
|
||||
}
|
||||
for (auto const & uuid : without_uuids)
|
||||
{
|
||||
value->without_uuids.insert(uuid);
|
||||
value->without_uuids.push_back(uuid);
|
||||
value->cache->without_uuids.push_back(uuid);
|
||||
}
|
||||
value->hash = component_hash(with_uuids, without_uuids);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue