-
Notifications
You must be signed in to change notification settings - Fork 201
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
Tiles probably should not be "children" of tilemaps #582
Comments
related to this, we should probably add an example of how we'd expect people to add things like colliders to the right locations relating to the tilemap/tile positioning. |
Not really in favor of this change. If the situation of having a Also, I'm not a Bevy expert at all, but after taking a quick look at the code it seems like it should not: https://github.com/bevyengine/bevy/blob/release-0.15.0/crates/bevy_render/src/view/visibility/mod.rs#L398 (to compare with the fix for |
Appreciate the feedback. We should dig back into the profiler, because my memory may be incorrect. I'm not sure how big of an issue it is either way. I should amend point I could see users wanting to attach stuff to their tiles and have visibility propagation work, but right now it won't. So it seems like a bit of a footgun. Maybe we should use |
Sounds like we should document answers to:
I asked in #engine-dev about Visibility and if its intended use was a match for our use case and I believe it is. Visibility in Bevy is a rendering concern, while TileVisibility in bevy_ecs_tilemap is also a rendering concern. Using Visibility to control both entire-tilemap rendering and tile rendering seems to make sense but it still might be worth doing a bit of a deeper dive into the places Visibility affects bevy's rendering before deciding to do it. Its always possible Bevy's Visibility implementation changes, but IMO our end-goal is to upstream tilemaps so being closer to upstream is better for that too. As for if this is even a possible change on the bevy_ecs_tilemap side, I think we need a bit more investigation. The only library-side use of the There's also
Biggest thing for this issue. We need some kind of profile to know what the baseline is and what this change could do perf wise. Doesn't seem like we have the numbers as of right now to say if there's even an issue. 0.14->0.15 improved perf something like 3x, so if there is a similar fix to the Transform fix to be made that could be really nice. re: the original issue
Tiles can totally have transforms. This is part of why I'd like to have a "how do we handle colliders" type example. Tiles are entities and thus can have any component on them, including transforms for collider positioning which feels like the first thing someone would think of for positioning colliders. Also worth noting that the collectathon example from bevy_ecs_ldtk has Transforms on it's tiles, and I assume that this is fairly common. fn log_tiles(query: Query<(Entity, &TilePos, Has<Transform>)>) {
for (entity, tilepos, has_transform) in &query {
info!(?entity, ?tilepos, ?has_transform);
}
}
TileStorage is a bit weird and by its current implementation this doesn't have to be true. I feel like the only reason it exists is to do efficient tile-position based entity access. In that sense its not really storage, but rather a user-maintained index. We've started using it more with 0.15's release (the The crate's core functionality actually works without |
Okay, I am pretty convinced that hierarchies of tilemaps and tiles can be useful.
I agree. It would be nice to get an idea of how
compare.
I'd only point out that according to our examples, I'd love for users to be able to just |
Don't know if it makes sense to actually have Currently, we have entities for tilemaps and tiles but we actually render chunks, which are not entities.
I guess we could have the same discussion about I think we should have the same strategy for
Maybe also has to do with the retained rendering stuff and not only the
Yes, and it's also how it is currently done for bevy_ecs_tiled when adding colliders from tiles. I'm actually changing this to attach (and merge them when possible) colliders from tiles on the tilemap rather than on tiles. I believe this kind of approach should be encouraged instead of spawning one collider per tile which does not work on "medium sized" maps.
I'd be very interested to see how this solution performs. If we have this kind of architecture, we could definitivelly have
I believe it already works ? :) |
Well, yes, if you place all of your tiles in a hierarchy. My big question is "do we want to teach Bevy users to do this universally?" Because we could easily provide a mechanism for this based on
Sprite performance is actually significantly worse in 0.15. I haven't done this sort of comparison with |
seems like 0.16 is going to improve relationships (and perf) as well: bevyengine/bevy#17398 |
There are a few reasons one might make use of Bevy's hierarchy:
I am reasonably sure that
1
and2
are not applicable tobevy_ecs_tilemap
. Tiles do not have transforms and visibility propagation to tiles is not needed -- tilemaps that are not visible will not be rendered.Using bevy's hierarchy comes with a performance penalty because due to visibility propagation work being done. (Also, prior to 0.15, transform propagation affected us too. See bevyengine/bevy#14384)
That just leaves
3
. The relationship between a tilemap and its tiles is already defined in the tilemap'sTileStorage
, so using Bevy's hierarchy is just duplicating this data. Instead of using recursive despawns, we could add anOnRemove
hook that drains theTileStorage
and despawns its entities.I saw this show up in profiling, but I'm writing this issue from memory and it has been a few weeks. I don't remember how significant this was.
The text was updated successfully, but these errors were encountered: