Closed kulkalkul closed 1 year ago
I rather like being able to use the immediate-mode style despite iced being a retained-mode framework. My rationale, for what it's worth, is as follows:
UpdateUI
type of event, which you are likely going to end up sending almost every frame anyway, like the Solar System example which just sends constant Tick
events.Changed
query because it's more expensive to check each entity for changes than it is to just for_each
it. It all depends on your particular game, of course, but determining whether or not you need to recreate the UI tree is often counterintuitively more expensive than just recreating the UI tree.I'll admit, it feels a little like we're abusing the iced library, hooking directly into its layout and rendering systems and bypassing the entire "front end" API, and maybe over time the vision of iced will diverge too much for this "immediate iced" to be maintainable - but for now, it handles that without even breaking a sweat, and the more recent work on the iced library points toward, not away from, support for "just the widgets" or "just the renderers". They are all distinct sub-crates now.
So, yes, bevy_iced is iced without Application
s or Shell
s, and that also means (more or less) without the normal update
cycle; the ECS takes their place, and that's A-OK as long as the renderer can keep up. If you really don't want anything to run except when there's user input, that's what WinitSettings::desktop_app()
is for.
@focustense does the iced project know about this use case? It would be sad if they didn't and made some architectural change that prevented this mode of use from working if it could have been avoided.
I've checked how update and view works in iced. They do not run unless user acts. Update iterates over bevy event, so I don't think that has any overhead. But view recalculates each frame as it is a system and that feels wrong.
Thinking about it, most bevy way of doing it could be using run conditions. Other option would be removing the system and using a struct just like how iced does and with systems to propogate updates or run view function. Then that struct could decide to recalculate view or use cached one.
What do you think? Btw, I'm spamming with issues but I hope you are available. 😅 I could experiment with it if you are busy.