matter icon indicating copy to clipboard operation
matter copied to clipboard

Without should narrow archetypes

Open memorycode opened this issue 1 year ago • 4 comments

Currently, using :without(Components.B) in a query is similar to querying normally, using world:get(Components.B) to check if the component is present, and using continue to skip the iteration (though faster.) This is intended behavior and is documented.

for id, a in world:get(Components.A):without(Components.B) do
    -- Do something
end

for id, a in world:get(Components.A) do
    if world:get(id, Components.B) do
        continue
    end
    
    -- Do something
end

However, this approach comes with a few downsides:

  • The cost of iteration on entities with excluded components is hidden.
  • The archetype is broader than required.

Giving :without the ability to narrow the archetype would resolve these issues, though the potential downsides outside of implementation complexity are unclear.

memorycode avatar Dec 22 '23 20:12 memorycode

I have put the wontfix label as I am kind of blocked on working on this until we fix our iterator to be more modular in #85

Ukendio avatar Dec 22 '23 20:12 Ukendio

I have made a possible solution for this, I will put it up when aforementioned issue is resolved.

Ukendio avatar Dec 22 '23 22:12 Ukendio

This isn't what the wontfix label is for. I've added the appropriate blocked label.

LastTalon avatar Dec 29 '23 13:12 LastTalon

Didn't know we had a blocked label :O

Ukendio avatar Dec 30 '23 20:12 Ukendio