-
Notifications
You must be signed in to change notification settings - Fork 85
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
Empty archetypes #66
Comments
It's intentional that the archetype sticks around; my thinking that if a certain combination of components existed once, it'll probably exist again, and this way we save some allocator pressure. That said, I agree that empty archetypes forcing serialization of queries is a bit silly. I'm not opposed to an explicit method to drop empty archetypes to recover memory, but I don't think it's a good solution to this specific problem due to the performance consequences described above. I think the way forward here is to provide an interface that behaves as if empty archetypes do not exist, even though their storage is retained. This should actually be pretty easy: slap a filter on to |
Well, this is how my usage of current API looks like - so, yes, adding a filter is an obvious idea, hence why I suggested exposing |
Updating the generation when an archetype becomes empty should handle that fine. Doing the filtering internally avoids expanding the API, which is desirable. |
Despawning all entities of an archetype doesn't remove that archetype from the world, and doesn't advance archetype generation.
This is problematic for something like my library
yaks
, because it causes tests like this one to fail - summarized, it:This means that as soon as a system-straddling entity is spawned those systems are forbidden from running concurrently until the world is recreated.
I see these approaches so far:
World::defrag()
that purges empty archetypes and advances the generation,::defrag()
ontoWorld::flush()
,Archetype::len()
and/or::is_empty()
, and... advancing the generation once an archetype is empty?The problem with last approach is obvious - the archetypes don't actually change - but there needs to be some mechanism of informing user code.
The text was updated successfully, but these errors were encountered: