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

Enable lenses to avoid change detection #124

Merged
merged 2 commits into from Apr 26, 2024
Merged

Enable lenses to avoid change detection #124

merged 2 commits into from Apr 26, 2024

Conversation

djeedai
Copy link
Owner

@djeedai djeedai commented Apr 26, 2024

Add the ability for all Lenses to avoid triggering change detection if they don't make any actual change to their target (component or asset).

This change modifies the signature of Lerp::lerp() to take &mut dyn Targetable<T> instead of &mut T. The Targetable<T> acts as a Mut<T>, marking the target as changed only if actually dereferenced mutably.

Note that we cannot use Mut<T> directly because we can't obtain a Mut<A: Asset> without marking the asset as mutable; see bevyengine/bevy#13104.

Fixes #91

Add the ability for all `Lens`es to avoid triggering change detection if
they don't make any actual change to their target (component or asset).

This change modifies the signature of `Lerp::lerp()` to take `&mut dyn
Targetable<T>` instead of `&mut T`. The `Targetable<T>` acts as a
`Mut<T>`, marking the target as changed only if actually dereferenced
mutably.

Note that we cannot use `Mut<T>` directly because we can't obtain a
`Mut<A: Asset>` without marking the asset as mutable; see
bevyengine/bevy#13104.

Fixes #91
@djeedai djeedai added the enhancement New feature or request label Apr 26, 2024
@djeedai djeedai merged commit 63ea415 into main Apr 26, 2024
8 checks passed
@djeedai djeedai deleted the u/mut branch April 26, 2024 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid unnecessary change detection resulting from component lens
1 participant