Set compatibleAchetype after without

This commit is contained in:
Ukendio 2024-04-29 02:30:10 +02:00
parent f79e757eea
commit d11fa2f4a3
3 changed files with 24 additions and 8 deletions

View file

@ -408,10 +408,7 @@ function World.query(world: World, ...: i53): any
function preparedQuery:without(...)
local components = { ... }
for i, component in components do
components[i] = component
end
for i = #compatibleArchetypes, 1, - 1 do
for i = #compatibleArchetypes, 1, -1 do
local archetype = compatibleArchetypes[i].archetype
local shouldRemove = false
for _, componentId in components do
@ -424,6 +421,12 @@ function World.query(world: World, ...: i53): any
table.remove(compatibleArchetypes, i)
end
end
lastArchetype, compatibleArchetype = next(compatibleArchetypes)
if not lastArchetype then
return noop()
end
return self
end

View file

@ -117,7 +117,23 @@ return function()
added += 1
end
expect(added).to.equal(hm)
print(added, hm)
end)
it("should skip iteration", function()
local Position, Velocity = world:entity(), world:entity()
print(Position, Velocity)
local e = world:entity()
print(e)
world:set(e, Position, Vector3.zero)
world:set(e, Velocity, Vector3.one)
local added = 0
for i in world:query(Position):without(Velocity) do
print(i)
added += 1
end
expect(added).to.equal(0)
end)
it("track changes", function()

View file

@ -23,9 +23,6 @@
"benches": {
"$path": "benches"
},
"rewrite": {
"$path": "matterRewrite"
},
"mirror": {
"$path": "mirror"
}