This commit is contained in:
Ukendio 2024-07-15 20:31:51 +02:00
parent 459e670ce9
commit 02548f2ac0

View file

@ -649,8 +649,8 @@ do
return nil return nil
end end
local records = archetype.records local tr = archetype.records
local columns = archetype.records local columns = archetype.columns
local row = record.row local row = record.row
local va = fetch(a, tr, columns, row) local va = fetch(a, tr, columns, row)
@ -855,23 +855,17 @@ do
end end
end end
local cache
function world_query(world: World, ...: number): Query function world_query(world: World, ...: number): Query
-- breaking? -- breaking?
if (...) == nil then if (...) == nil then
error("Missing components") error("Missing components")
end end
indices = {} indices = {}
compatibleArchetypes = {}
length = 0 length = 0
components = { ... } components = { ... }
if cache then
compatibleArchetypes = cache
else
compatibleArchetypes = {}
local archetypes: { Archetype } = world.archetypes :: any local archetypes: { Archetype } = world.archetypes :: any
local firstArchetypeMap: ArchetypeMap local firstArchetypeMap: ArchetypeMap
local componentIndex = world.componentIndex local componentIndex = world.componentIndex
@ -913,8 +907,6 @@ do
indices[length] = records indices[length] = records
end end
cache = compatibleArchetypes
end
lastArchetype = 1 lastArchetype = 1
archetype = compatibleArchetypes[lastArchetype] archetype = compatibleArchetypes[lastArchetype]