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

[ecs] Split DetectChanges into SetChanged #2330

Closed

Conversation

NathanSWard
Copy link
Contributor

Objective

  • Currently any sort of struct that tracks change detection (either immutably or mutably) has duplicated code.
  • There was a previous attempt to coalesce these into a trait DetectChanges however that did not cover the use case for immutable change detection (such as Res<T>)

Solution

  • Split the implementation of DetectChanges to also have a SetChanged trait where the SetChanged trait is only implemented for the mutable change detection structs.

@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Jun 10, 2021
@NathanSWard NathanSWard added C-Code-Quality A section of code that is hard to understand or change A-ECS Entities, components, systems, and events and removed S-Needs-Triage This issue needs to be labelled labels Jun 10, 2021
@NathanSWard
Copy link
Contributor Author

It looks like we'll need to eventually introduce a trait for getting the value of a thing that implements change detection.
And more specifically, get the value mutably without triggering change detection.
This is really the only way to fix #2343

Ideally I'd like to build that PR on top of this one, so I'll try to push for this to get merged soon. :)

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I think I'm in favor of this refactor.

@alice-i-cecile
Copy link
Member

It's a little strange to me that ComponentTicks is in a separate file: could we condense this into change_detection.rs?

@NathanSWard NathanSWard force-pushed the nward/detect-changes-trait branch from 51da589 to c9b16ed Compare June 22, 2021 16:04
@NathanSWard
Copy link
Contributor Author

Sorry for being dormant on this PR, I just pushed some changes and rebased onto main.
If you can take a look @alice-i-cecile I'd appreciate and then maybe we can flag this as ready for final review :)

@MinerSebas
Copy link
Contributor

This has currently conflicts due to #2345.
@NathanSWard should I send you a PR to your Fork to fix this, or do you want to fix this yourself?

@NathanSWard
Copy link
Contributor Author

This has currently conflicts due to #2345.
@NathanSWard should I send you a PR to your Fork to fix this, or do you want to fix this yourself

Thanks for reminding me about this @MinerSebas !
I should be able to address the merge conflicts sometime today/tomorrow

@NathanSWard NathanSWard force-pushed the nward/detect-changes-trait branch from 6dcf833 to 67c81d8 Compare June 28, 2021 19:08
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jul 16, 2021
@NathanSWard NathanSWard requested a review from mockersf July 20, 2021 05:05
@NathanSWard
Copy link
Contributor Author

ping @cart @mockersf
I think this is ready to go

@cart cart added the S-Pre-Relicense This PR was made before Bevy added the Apache license. Cannot be merged or used for other work label Jul 23, 2021
@mockersf mockersf removed the S-Pre-Relicense This PR was made before Bevy added the Apache license. Cannot be merged or used for other work label Jul 24, 2021
@alice-i-cecile
Copy link
Member

No longer needed; closing this out :)

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-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants