Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filters doesn't exclude disabled objects #973

Open
Tisten opened this issue Apr 28, 2023 · 1 comment
Open

Filters doesn't exclude disabled objects #973

Tisten opened this issue Apr 28, 2023 · 1 comment
Labels
enhancement New feature or request will take a while This will take a while

Comments

@Tisten
Copy link

Tisten commented Apr 28, 2023

Describe the bug
After disabling a tag or component on an entity, a query for it will no longer return the entity. But filters will.

To Reproduce
I wrote a test for it. It is an adapted version of EnabledComponents_query_disabled:

void EnabledComponents_filter_disabled() {
    ecs_world_t *world = ecs_mini();

    ECS_COMPONENT(world, Position);

    ecs_entity_t e1 = ecs_new(world, Position);
    ecs_entity_t e2 = ecs_new(world, Position);
    ecs_entity_t e3 = ecs_new(world, Position);

    ecs_enable_component(world, e1, Position, true);
    ecs_enable_component(world, e2, Position, false);

    ecs_filter_t f = ECS_FILTER_INIT;
    test_assert(NULL != ecs_filter_init(world, &(ecs_filter_desc_t){
        .storage = &f,
        .expr = "Position"
    }));
    ecs_iter_t it = ecs_filter_iter(world, &f);

    int32_t table_count = 0, count = 0;

    while (ecs_filter_next(&it)) {
        int32_t i;
        for (i = 0; i < it.count; i ++) {
            test_assert(it.entities[i] != e2);
            test_assert(it.entities[i] == e1 || it.entities[i] == e3);
            test_assert(ecs_is_enabled_component(world, it.entities[i], Position));
        }
        count += it.count;
        table_count ++;
    }

    test_int(count, 2);
    test_int(table_count, 2);

    ecs_fini(world);
}
@SanderMertens
Copy link
Owner

SanderMertens commented May 8, 2023

Right, there are a few features that rely on specialized iteration inside of tables, which is currently only supported by queries:

  • Disabled components
  • Union relationships
  • Flattened hierarchies

Adding support for these features are on the roadmap but may take some time to complete, as the plan is to integrate them with the rule engine, and eventually have the rule engine replace the filter implementation.

I'm marking this as enhancement since it's not expected to work (yet).

@SanderMertens SanderMertens added enhancement New feature or request will take a while This will take a while and removed bug Something isn't working labels May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request will take a while This will take a while
Projects
None yet
Development

No branches or pull requests

2 participants