Skip to content
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

Fix issue switching between scenes with many entities #5605

Merged
merged 1 commit into from
Jul 22, 2022

Conversation

netpro2k
Copy link
Contributor

When switching between scenes with > 100 entities (which is not even all that many) BitECS's entity id recycling causes some strange behavior in our object3d cleanup code.

image

This PR (along with a patch to BitECS) allows entity id recycling to be configured, and configures it to 20% of our 10,000 entity max (2000). This points at our own fork of BitECS for now until the change lands upstream. This is still only a partial solution, as the issue would still happen if entities are added on a frame where > 2000 entities were also removed, but this is very unlikely to happen.

There was some discussion of further solutions on github and discord

@netpro2k netpro2k merged commit 7c7adb1 into master Jul 22, 2022
@netpro2k netpro2k deleted the fix-scene-switching-eid-recycle branch July 22, 2022 03:20
@takahirox
Copy link
Contributor

Curious to know, any downside of choosing 20% that is much greater than the default 1%? The recycling process time can be longer?

@netpro2k
Copy link
Contributor Author

There is no cost to the "recycling" itself, its just a difference in addEntity between an id coming from the removed ids array or the next incremental entity id (https://github.com/NateTheGreatt/bitECS/pull/93/files#diff-4833659b31bb551bd2b6b1f136dee5686fcbcc1c29fb9de498950066d591eb62R87). The "cost" of not recycling is sooner is that you get a bit more memory fragmentation in your component data arrays.

@takahirox
Copy link
Contributor

Thanks, probably better memory fragmentation may not be our first priority then 20% is acceptable for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants