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

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

Open
SanderMertens opened this issue Jan 27, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@SanderMertens
Copy link
Owner

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.

@SanderMertens SanderMertens added the enhancement New feature or request label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant