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

Data Locality: Double Linked Entities #347

Open
ItsShadowCone opened this issue Apr 2, 2019 · 0 comments
Open

Data Locality: Double Linked Entities #347

ItsShadowCone opened this issue Apr 2, 2019 · 0 comments

Comments

@ItsShadowCone
Copy link

At the section about entity components and memory handling there's basically two options proposed for accessing neighboring components.

1: full entities wherever you need them with pointers to each component. Problem: accessing an entity when you only have a component.
2. Each component has an entity id. Easy to get to the entity but expensive to access the individual components.

What's the key catch with having double linked entities? Namely each component having a pointer to the entity and each entity having a pointer to each other component. Sure, it's two pointer indirections, but it still seems better than either of those listed above. Memory cost per component should be marginal, components can be freely relocated (move data, chase pointer to entity, update the pointer pointing back), entities can as well be relocated (just iterate and do the same thing for every component, more costly, sure, but better than manually looking them all up). Furthermore, the entity itself could act like a service locator and you could theoretically disable an entities' component by replacing the pointer to it with a null version of the same thing.

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

No branches or pull requests

1 participant