-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Basic inherited components/entity prefabs #18767
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
Draft
eugineerd
wants to merge
17
commits into
bevyengine:main
Choose a base branch
from
eugineerd:inherited-components
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
193cc01
pass `TableId` to `set_table`
eugineerd ace3ef5
add base inherited components implementation
eugineerd 5c77668
add `InheritedComponents` to world
eugineerd e2eb140
add inherited components support to `Archetype` and `Table`
eugineerd a5ca15f
Initialize and update inherited components.
eugineerd 51cf2ff
make `world.get_*` methods respect inherited components
eugineerd efc05d6
make `Query` respect inherited components
eugineerd ce6b4a8
Fix iteration speed regression when not using inherited components.
eugineerd d09146c
actually working version
eugineerd 494793c
finish inherited mutable components poc
eugineerd 655d101
make poc compile with everything
eugineerd ead7fd4
Merge branch 'main' of https://github.com/bevyengine/bevy into inheri…
eugineerd 566e961
update to main
eugineerd 1b94cd1
pointer-based `MutInherited`
eugineerd 05ab309
Big rewrite for shared mutable components.
eugineerd 9a5dafe
fix abnormally slow foreach performance
eugineerd 65627e0
fixed bug, more regressions :(
eugineerd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done a review yet, but this PR seems similar in shape to the Flecs approach, which is cool and worthy of consideration, but I've always been hesitant about it. My biggest concerns about that approach:
Mut
"smart" and have it check on every access whether it can write directly to the pointer or whether it needs to queue up a command to "clone on write"? That would introduce massive overhead as Mut is very "hot". Do we make only immutable components inheritable? If so then this system becomes effectively useless for prefabs, as we need a prefab system to support the whole range of bevy components.There are certainly benefits to this model (memory usage and "inherited spawn speed" being big ones). But before taking a single step on this road (in terms of merged features), I'd want satisfying / holistic answers to all of those questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've though about these concerns when working on this implementation, I think it should be possible?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will also add a fixed cost to
Query::get
andEntityWorldMut::get
ops right?This was referring to two entities that both inherit from a third entity both trying to mutably access the same component.
I'm curious to see what Mut COW looks like in practice. There are also corner cases to consider like two queries in a query set that both access the same (inherited) component mutably. How would they coordinate to ensure that both changes are applied / they don't step on each other? Note that structural changes cannot be applied within a normal system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm dubious of the overhead and complexity this will introduce, but I'm also very excited and curious to see where this lands!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there's a flag for the archetype and the lookup is done only if the archetype contains any inherited components, which is what flecs does.
We can make a staging hashmap for inherited components that have been mutated during system runtime and return them if they're requested multiple times in the same system, if I understood your question.