Fixes a bug when >1 entities are added to and removed from 1 family in the same frame #59
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.
This should fix a small bug in the family code, namely one that occurs whenever the following is given:
This bug then lead to only one of the entities to be properly updated.
The steps within the code, that lead to this problem are as following:
During the first iteration it picks entities[0] {1(old}} and finds it in toRemove, deletes it from there and swaps it with entities[3]{ 2(new) }, leading to the following situation:
During the second iteration, it picks entities[0] {2(new)} and finds it in toRemove, deletes it from there and swaps it with entities[2] {1(new)}, leading to the final situation:
Which then leads to 2(new) and 1(old) to be deleted
This change buffers the swaps in a vector, before executing them all at once, ensuring that the swaps already executed don't change the result of later forward scans through entities.