-
Notifications
You must be signed in to change notification settings - Fork 4
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
Reactive components #11
Comments
I have ran into the same situation and thought about this relatively deeply before. Some of my thoughts:
A little along the lines of your last idea could be also to have a To summarize:
I will look again at how |
If you enforce synchronized execution inside the Observable it would be deterministic, wouldn't it? input.val = :blue
converted.val = convert_color(input.val)
texture.val = to_texture(converted.val)
In the context of a game engine maybe not. I'd say it's fairly common with plotting though. Most plot entities will be static and when they change it's often just one or two components. E.g. I have made arrows plots where I only wanted to adjust a rotation vector, or a mesh plot where I'm only adjusting colors. Things controlled by sliders also often end up controlling just one component for me.
That's pretty much just an |
Sorry with component I meant |
Links in the following discussion might be of interest to you: traffaillac/traffaillac.github.io#1 . |
This is partially just me thinking out loud, but maybe it's good to discuss this and start some "best practices" style documentation as well. Some components naturally have a reactive relationship. For example you only want to run conversion pipeline
Vector{Symbol} -> Vector{RGBA} -> Texture
when the input is updated. There are a couple of ways one could achieve this:Observables
I think Observables are pretty clean in this case, and maybe also the fasted way to do things. It seems like EnTT also supports something along those lines. Perhaps it makes sense to implement a light observable type for this, which restricts what you are allowed to do. E.g. only one synchronized callback?
Per component
has_changed
orneeds_update
If we want to avoid Observables using mutable components that keep track of whether they have changed/need updates could work. I guess this would be faster when updates are frequent and slower if they are rare.
Update buffer
Another option would be to keep track of entity-component pairs that need updates in a buffer. I assume this ends up being worse in general as you're frequently searching through the buffer.
There are couple of alternatives that follow the same idea. For example, the buffer could be moved to the system. That would make it smaller and the components could be implied depending on how things are set up. You still have frequent de/allocations though.
Another possibility would be a more trait-like update component. It also avoids needing to check component types, but we're still essentially filling and clearing arrays frequently.
My impression is:
has_changed
fields are best when updates are frequent and many of the same component type need updatesThe text was updated successfully, but these errors were encountered: