Repository navigation
Preserve entity identities across World.TrimExcess - #316
Closed
snowyukitty wants to merge 1 commit into
Closed
snowyukitty wants to merge 1 commit into
snowyukitty wants to merge 1 commit into
Conversation
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.
Fixes #315.
TrimExcess()currently drops recycled IDs above the reduced chunk capacity. Once the remaining queue is exhausted, entity creation falls back toSize, which can reuse the ID and version of a surviving entity. Trimming an empty world also loses the versions needed to keep destroyed handles invalid.Preserve the recycled ID/version queue with
Queue.TrimExcess()instead of filtering its contents. The shared allocator restores entity metadata capacity when an ID is outside the trimmed array, so both single and batch creation can safely reuse high IDs without retaining all metadata after a trim. Chunk storage still shrinks, while recycled IDs retain the generations required for safe reuse.Regression tests cover surviving entities and their component values, high recycled IDs over repeated trim/reuse cycles, and destroyed handles after empty-world trimming. Each scenario exercises single and batch creation. The existing trimming test also checks that reusing its first high ID stays in bounds.
Validation: built all library target frameworks and ran the complete NUnit suite for Debug, Debug-Events, Debug-PureECS, Release, Release-Events, and Release-PureECS. All six new regression cases fail on the unmodified upstream base.