Skip to content

Implement component inheritance as a storage feature#2113

Open
SanderMertens wants to merge 12 commits into
masterfrom
component_inheritance_storage
Open

Implement component inheritance as a storage feature#2113
SanderMertens wants to merge 12 commits into
masterfrom
component_inheritance_storage

Conversation

@SanderMertens
Copy link
Copy Markdown
Owner

@SanderMertens SanderMertens commented May 27, 2026

This PR makes component inheritance work for most flecs APIs, in addition to queries (which already works):

world.component<Base>();
world.component<Foo>().is_a<Base>();
world.component<Bar>().is_a<Base>();

flecs::entity e = world.entity("e")
  .add<Foo>()
  .add<Bar>();

e.has<Base>(); // true
Base& b = e.get<Base>(); // returns first matching

This PR implements the following changes:

  • sink component inheritance into the storage, so it becomes available for all APIs
  • get, has, owns, each now work with inheritance
  • queries for inherited components are now cacheable
  • queries for inherited components now use the correct stride when matching a derived type
  • inheritance support is added to reflection, so types can inherit from each other

@SanderMertens SanderMertens force-pushed the component_inheritance_storage branch 14 times, most recently from 6230716 to 9dd433c Compare May 28, 2026 06:30
Comment thread src/query/engine/engine.h Outdated
Comment thread include/flecs/addons/cpp/delegate.hpp
Comment thread src/query/engine/eval.c Outdated
Comment thread src/storage/table.c Outdated
Comment thread src/iter.c
Comment thread src/observable.c Outdated
Comment thread test/core/src/ComponentInheritance.c
@SanderMertens SanderMertens force-pushed the component_inheritance_storage branch from 9dd433c to c9144be Compare May 28, 2026 22:54
@SanderMertens SanderMertens force-pushed the component_inheritance_storage branch from b4e55ec to 9a70cff Compare May 29, 2026 01:23
@SanderMertens SanderMertens force-pushed the master branch 2 times, most recently from 3ca6d73 to e3f4d11 Compare May 29, 2026 16:32
@SanderMertens SanderMertens force-pushed the component_inheritance_storage branch from 0e37ca0 to 2edca0d Compare May 29, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant