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,9 +408,6 @@ function World.query(world: World, ...: i53): any
function preparedQuery:without(...) function preparedQuery:without(...)
local components = { ... } 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 archetype = compatibleArchetypes[i].archetype
local shouldRemove = false local shouldRemove = false
@ -424,6 +421,12 @@ function World.query(world: World, ...: i53): any
table.remove(compatibleArchetypes, i) table.remove(compatibleArchetypes, i)
end end
end end
lastArchetype, compatibleArchetype = next(compatibleArchetypes)
if not lastArchetype then
return noop()
end
return self return self
end end

View file

@ -117,7 +117,23 @@ return function()
added += 1 added += 1
end end
expect(added).to.equal(hm) 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) end)
it("track changes", function() it("track changes", function()

View file

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