Skip to content

Make entity generation a new type and remove identifier #19121

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

Conversation

ElliottjPierce
Copy link
Contributor

Objective

This is a followup to #18704 . There's lots more followup work, but this is the minimum to unblock #18670, etc.

This direction has been given the green light by Alice here.

Solution

I could have split this over multiple PRs, but I figured skipping straight here would be easiest for everyone and would unblock things the quickest.

This removes the now no longer needed identifier module and makes Entity::generation go from NonZeroU32 to struct EntityGeneration(u32).

Testing

CI

@ElliottjPierce ElliottjPierce added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change X-Blessed Has a large architectural impact or tradeoffs, but the design has been endorsed by decision makers S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 7, 2025
Copy link
Contributor

@bushrat011899 bushrat011899 left a comment

Choose a reason for hiding this comment

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

Mostly just some nitpicking. The changes look good and I love that this PR demonstrates the rolling updates we can do to migration guides.


/// Returns the [`EntityGeneration`] that would result from this many more `versions` of the corresponding [`EntityRow`] from passing.
#[inline]
pub const fn after_versions(self, versions: u32) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

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

Future PR: might be nice to implement Iterator<Item = Self> for EntityGeneration. That gives an idiomatic next method.

@atlv24 atlv24 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels May 7, 2025
Copy link
Contributor

@manokara manokara left a comment

Choose a reason for hiding this comment

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

Noticed some typos in the migration guide

ElliottjPierce and others added 2 commits May 7, 2025 22:11
Co-authored-by: Mark Nokalt <marknokalt@live.com>
@ElliottjPierce
Copy link
Contributor Author

Benchmarks looks good, sparse set change detection was the only thing that was slowed down by anything notable. But I don't think that's a big deal. Other than that, I think this is generally an improvement in perf. (Less checks when changing the generation.)

Also want to point out that we loose a niche on EntityMeta here, but it can be added back shortly (via TableRow and ArchetypeRow). And I wanted to call out the big stability warning on Entity which gives me more confidence that this breaking change should be ok.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue May 8, 2025
Merged via the queue into bevyengine:main with commit 12aba64 May 8, 2025
32 checks passed
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 X-Blessed Has a large architectural impact or tradeoffs, but the design has been endorsed by decision makers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants