Skip to content

Commit

Permalink
test(ecs): cover QueryFilter with relations
Browse files Browse the repository at this point in the history
  • Loading branch information
RiscadoA committed Jan 24, 2024
1 parent f736c20 commit 779027b
Show file tree
Hide file tree
Showing 2 changed files with 628 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/src/cubos/core/ecs/query/filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ void QueryFilter::update()

for (const auto& term : mTerms)
{
// Filter out non 'without component' terms.
if (!term.isComponent(mWorld.types()) || !term.component.without)
// Filter out non 'without component' terms and terms with different targets.
if (!term.isComponent(mWorld.types()) || !term.component.without ||
term.component.target != targetIndex)
{
continue;
}
Expand Down Expand Up @@ -397,6 +398,7 @@ void QueryFilter::View::Iterator::advance()
mCursorRows[filter.mTargetCount] >= world.tables().sparseRelation().at(link.tables[mIndex]).size())
{
++mIndex;
mCursorRows[filter.mTargetCount] = 0;
}
}
else if (mView.mPins[link.fromTarget].isNull())
Expand Down Expand Up @@ -480,7 +482,8 @@ void QueryFilter::View::Iterator::advance()

// Find the index of the table which matches the pinned entities.
mIndex = 0;
while (link.tables[mIndex].from != fromArchetype || link.tables[mIndex].to != toArchetype)
while (mIndex < link.tables.size() &&
(link.tables[mIndex].from != fromArchetype || link.tables[mIndex].to != toArchetype))
{
++mIndex;
}
Expand Down
Loading

0 comments on commit 779027b

Please sign in to comment.