Skip to content

Make component inheritance work with returning component references in queries #1537

@SanderMertens

Description

@SanderMertens

Describe the problem you are trying to solve.
Currently queries do not return correct component references (pointers) for components matched with component inheritance. For example:

struct A {
  int x;
}:
struct B : public A {
  int y;
}

world.component<B>().is_a<A>();

world.query<A>()
  .each([](A& a) {
    // if `B` is matched, `a` might not be correct
  });

The reason this happens is because the query uses the size of a to iterate, where it should use the size of the matched component.

Describe the solution you'd like
Queries should return valid component references when component inheritance is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions