Skip to content

Conversation

ElliottjPierce
Copy link
Contributor

Objective

Progresses #17569. The end goal here is to synchronize component registration. See the other PR for details for the motivation behind that.

For this PR specifically, the objective is to decouple Components from Storages. What components are registered etc should have nothing to do with what Storages looks like. Storages should only care about what entity archetypes have been spawned.

Solution

Previously, this was used to create sparse sets for relevant components when those components were registered. Now, we do that when the component is inserted/spawned.

This PR proposes doing that in BundleInfo::new, but there may be a better place.

Testing

In theory, this shouldn't have changed any functionality, so no new tests were created. I'm not aware of any examples that make heavy use of sparse set components either.

Migration Guide

  • Remove storages from functions where it is no longer needed.
  • Note that SparseSets are no longer present for all registered sparse set components, only those that have been spawned.

Copy link
Contributor

@SpecificProtagonist SpecificProtagonist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me, and the unsafe code is still sound (as far as I can tell).

Note that SparseSets are no longer present for all registered sparse set components, only those that have been spawned.

Maybe also add a comment to that effect on Storages.sparse_sets?

@ElliottjPierce
Copy link
Contributor Author

Maybe also add a comment to that effect on Storages.sparse_sets?

Done! Thanks @SpecificProtagonist for the review and suggestions.

Github doesn't run fmt or course for commits from a review.
Copy link
Contributor

@chescock chescock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for pulling this out of the larger PR!

@chescock chescock added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Feb 4, 2025
@alice-i-cecile
Copy link
Member

Good stuff; I think this is a worthwhile cleanup regardless of the final design choice.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 5, 2025
Merged via the queue into bevyengine:main with commit 1b2cf7d Feb 5, 2025
28 checks passed
@ElliottjPierce ElliottjPierce deleted the isolate-component-registration branch February 5, 2025 20:16
mrchantey pushed a commit to mrchantey/bevy that referenced this pull request Feb 17, 2025
# Objective

Progresses bevyengine#17569. The end goal here is to synchronize component
registration. See the other PR for details for the motivation behind
that.

For this PR specifically, the objective is to decouple `Components` from
`Storages`. What components are registered etc should have nothing to do
with what Storages looks like. Storages should only care about what
entity archetypes have been spawned.

## Solution

Previously, this was used to create sparse sets for relevant components
when those components were registered. Now, we do that when the
component is inserted/spawned.

This PR proposes doing that in `BundleInfo::new`, but there may be a
better place.

## Testing

In theory, this shouldn't have changed any functionality, so no new
tests were created. I'm not aware of any examples that make heavy use of
sparse set components either.

## Migration Guide

- Remove storages from functions where it is no longer needed.
- Note that SparseSets are no longer present for all registered sparse
set components, only those that have been spawned.

---------

Co-authored-by: SpecificProtagonist <vincentjunge@posteo.net>
Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants