Add a structural Version to Archetype for cheap change detection - #310
Open
lgarczyn wants to merge 1 commit into
Open
Add a structural Version to Archetype for cheap change detection#310lgarczyn wants to merge 1 commit into
lgarczyn wants to merge 1 commit into
Conversation
Version is a monotonic counter that advances whenever an entity enters or leaves an archetype. It is advanced inside the EntityCount setter, the only way to change the count, so every add, remove, move, clear and bulk restore path advances it with no way to bypass, the Dangerous serialization extensions included. It lets a query detect structural change by comparing the Version of its matched archetypes, O(archetypes), instead of hashing every entity id, O(entities). Unchanged versions guarantee unchanged membership. A same-count remove-then-add swap still advances the Version, which an EntityCount comparison alone would miss.
lgarczyn
force-pushed
the
archetype-structural-version
branch
from
July 16, 2026 01:12
364db03 to
1a5ad40
Compare
Owner
|
Looks, good. Thanks! Im about to merge this :) do you any Idea what other Features can ne build on top of this? Just for the Future? ^^ |
Author
For me it's just the ability to gate systems on if new entities died or appeared, I want to build a dumb class tbat stores the previous versions of every archetype in a query, and return a bool if the version changed on any of them |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Version is a monotonic counter that advances whenever entities enter or leave an archetype, at every EntityCount mutation site: Add, AddAll, Remove, Clear and Copy.
It lets a query detect structural change by folding the Version of its matched archetypes, O(archetypes), instead of hashing every entity id, O(entities). Unchanged folds guarantee unchanged membership. A same-count remove-then-add swap still advances the Version, which an EntityCount comparison alone would miss.