tasgon / bevy_iced

Iced integration for Bevy
Other
122 stars 14 forks source link

Update and view being systems #7

Closed kulkalkul closed 1 year ago

kulkalkul commented 1 year ago

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.

focustense commented 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:

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 Applications or Shells, 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.

tbillington commented 1 year ago

@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.