-
Notifications
You must be signed in to change notification settings - Fork 199
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
Tile entities are leaked upon recursively despawning the Map entity #18
Comments
Thanks for the report! I think we likely will want a |
They don't necessarily need to be children of chunks, do they? |
Part of the issue with having tiles be a child of the map entity or the chunk entity is that tiles don't have standard transforms, and bevy currently complains about that. We could give them standard transforms, but then its just a lot of extra data that is not needed and people might assume that changing a tile transform would change where a tile is located which isn't supported and isn't easy to support. |
If that's the case, maybe we should suggest fixing it in Bevy. I don't see any reason why entities should be forced to have a Transform in order to be part of a hierarchy. Parent-child relationships are useful for a lot of things not related to positioning, such as in this case, for organizational purposes to make it easier to despawn all sub-entities when despawning the container entity. |
Bevy relations RFC would fix this issue. :) See: |
Yeah, this would probably allow it, assuming you can have the ECS enforce the deletion of certain relation types when their container entity is despawned. |
@forbjok I ran some tests with this, and I discovered a performance drop almost in half due to having a parent per child. If I instead have a |
Interesting. I wonder why that would affect performance when tiles don't have transforms that would need to be propagated. Have you looked into why it's affecting performance? |
The performance is mainly lost due to how |
You can now use |
When the Map entity is despawned with .despawn_recursive(), all tile entities belonging to that tilemap continue to exist even though they are no longer visible. As far as I can tell, this is due to the tile entities not being marked as children of the Map entity.
The text was updated successfully, but these errors were encountered: