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

Change detection with interior mutability #1661

Closed
alice-i-cecile opened this issue Mar 15, 2021 · 1 comment
Closed

Change detection with interior mutability #1661

alice-i-cecile opened this issue Mar 15, 2021 · 1 comment
Labels
A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use

Comments

@alice-i-cecile
Copy link
Member

alice-i-cecile commented Mar 15, 2021

What problem does this solve or what need does it fill?

Because we rely on DerefMut to detect changes, we can't

What solution would you like?

Best practices and advice are clearly documented for end users.

What alternative(s) have you considered?

Yup not much we can do about this short of making it easy for developers to trigger a change manually. In cases where interior mutability is needed, deref_mut() can't be called anyway (because interior mutability enables mutations from read-only contexts). Maybe adding a commands.set_changed::<T>(entity) command to make it easy for people to queue up changes in read only contexts without actually needing to mutate the component?.

Additional context

First brought up in the context of #1471. This behavior exists both before and after the changes in that PR.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use help wanted labels Mar 15, 2021
@Ratysz
Copy link
Contributor

Ratysz commented Mar 16, 2021

I posit that anyone understanding what "interior mutability" is also realises that it will not set a "this was accessed mutably" flag. More documentation is good, but just a "this only works on full mutable access, so interior mutability will not trigger it" should do here.

A form of commands.set_changed::<T>(entity) is not an alternative: it's a new feature that should probably be a thing anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

2 participants