Skip to content
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

Legion change events are fired for all mut queries #6

Closed
cart opened this issue May 17, 2020 · 5 comments
Closed

Legion change events are fired for all mut queries #6

cart opened this issue May 17, 2020 · 5 comments

Comments

@cart
Copy link
Member

cart commented May 17, 2020

Legion component change events / filters are fired whenever a system query contains Write<Component>. This makes these events useless for logic that needs to run when components are actually changed / as an optimization.

This might be solvable with some custom RefMut logic:

struct RefMut<T> {
  // other members
  modified: bool,
}

impl Deref for RefMut<T>
// on deref, set modified to true

// inside IntoSystem
query.iter(world) {
(a.fire(subscribers), b.fire(subscribers))
}
@Moxinilian
Copy link
Member

Moxinilian commented Jun 25, 2020

Oh my, yes why did we not think of that in Amethyst. The nuance between Deref and DerefMut makes it ideal to detect between simple check read and actual modification in many cases.

Could this be expanded to also trigger some “event” in case an actual mutation happens? It seems harder as it means the components would somehow point back to their archetype chunk to mark the chunk as containing change. But maybe it is achievable.

@cart
Copy link
Member Author

cart commented Jun 25, 2020

Yeah the Deref/DerefMut distinction is definitely what makes this viable. Rust is so great :)

And yeah i do think its worth exploring "on mutate" events. I'm pretty sure legion already has event infrastructure for cases like this that feeds off of the archetype change state. We might even get it for free if we implement this using the same approach as the existing mutation events!

@cart
Copy link
Member Author

cart commented Jul 12, 2020

As we are no longer using legion, im closing this in favor of #54

@Moxinilian
Copy link
Member

I believe you forgot to close it!

@cart
Copy link
Member Author

cart commented Jul 12, 2020

Bawhaha I certainly did 😊

@cart cart closed this as completed Jul 12, 2020
superdump referenced this issue in superdump/bevy Jul 8, 2021
Directional light and shadow
cart pushed a commit that referenced this issue Jul 24, 2021
Directional light and shadow
cart pushed a commit that referenced this issue Jul 24, 2021
Directional light and shadow
robtfm pushed a commit to robtfm/bevy that referenced this issue Mar 3, 2023
kettle11 pushed a commit to kettle11/bevy that referenced this issue May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants