-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[Merged by Bors] - ExtractResourcePlugin #3745
Conversation
Should we use a ExtractResource trait to specify the extract method explicitly like we do for components? Is there a use case where we want to do something else than simply clone the component/resource into the render world? |
Yup, that is definitely a use case as there are multiple instances of resource extraction systems that do something beyond just cloning. I'll look into it.
I was thinking that it would be good to go through and make use of ExtractComponentPlugin 'everywhere' now too. Mmm, perhaps that could be a reasonable approach... not requiring |
I had a go at adding an |
I really like those changes. The new plugin and its derive macro should make the extraction process way more ergonomic and should remove some boilerplate from user code. I am not familiar with macros as well, but the rest LGTM. |
Yeah, I think keeping this PR to be only about extracting resources is a good idea, so I didn't look into the derive macro for extracting components. If we like the pattern here and we think it makes sense for components too then I can make another PR for that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new bevy_render_macros
crate also needs to be added to the ./tools/publish.sh script
Done. |
a4f7fd9
to
dc90e02
Compare
8da17f1
to
009f982
Compare
009f982
to
0b97a9d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm on board for this generally, but I'd like us to consider an alternative trait design.
Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
Co-authored-by: MinerSebas <66798382+MinerSebas@users.noreply.github.com>
…extract_component
0b97a9d
to
38013fd
Compare
@cart any further comments or is this good to go now? |
This has been sitting for a couple weeks, and isn't controversial. I've done a final pass and I'm going to merge it in. We can tweak it further once it's in as we build on it. |
bors r+ |
Merge conflict. |
@superdump can you rebase? |
Merged in main. |
bors r+ |
# Objective - Add an `ExtractResourcePlugin` for convenience and consistency ## Solution - Add an `ExtractResourcePlugin` similar to `ExtractComponentPlugin` but for ECS `Resource`s. The system that is executed simply clones the main world resource into a render world resource, if and only if the main world resource was either added or changed since the last execution of the system. - Add an `ExtractResource` trait with a `fn extract_resource(res: &Self) -> Self` function. This is used by the `ExtractResourcePlugin` to extract the resource - Add a derive macro for `ExtractResource` on a `Resource` with the `Clone` trait, that simply returns `res.clone()` - Use `ExtractResourcePlugin` wherever both possible and appropriate
# Objective - Add an `ExtractResourcePlugin` for convenience and consistency ## Solution - Add an `ExtractResourcePlugin` similar to `ExtractComponentPlugin` but for ECS `Resource`s. The system that is executed simply clones the main world resource into a render world resource, if and only if the main world resource was either added or changed since the last execution of the system. - Add an `ExtractResource` trait with a `fn extract_resource(res: &Self) -> Self` function. This is used by the `ExtractResourcePlugin` to extract the resource - Add a derive macro for `ExtractResource` on a `Resource` with the `Clone` trait, that simply returns `res.clone()` - Use `ExtractResourcePlugin` wherever both possible and appropriate
# Objective - Add an `ExtractResourcePlugin` for convenience and consistency ## Solution - Add an `ExtractResourcePlugin` similar to `ExtractComponentPlugin` but for ECS `Resource`s. The system that is executed simply clones the main world resource into a render world resource, if and only if the main world resource was either added or changed since the last execution of the system. - Add an `ExtractResource` trait with a `fn extract_resource(res: &Self) -> Self` function. This is used by the `ExtractResourcePlugin` to extract the resource - Add a derive macro for `ExtractResource` on a `Resource` with the `Clone` trait, that simply returns `res.clone()` - Use `ExtractResourcePlugin` wherever both possible and appropriate
Objective
ExtractResourcePlugin
for convenience and consistencySolution
ExtractResourcePlugin
similar toExtractComponentPlugin
but for ECSResource
s. The system that is executed simply clones the main world resource into a render world resource, if and only if the main world resource was either added or changed since the last execution of the system.ExtractResource
trait with afn extract_resource(res: &Self) -> Self
function. This is used by theExtractResourcePlugin
to extract the resourceExtractResource
on aResource
with theClone
trait, that simply returnsres.clone()
ExtractResourcePlugin
wherever both possible and appropriate