Make ExtractComponentPlugin etc. generic on AppLabel#24423
Open
Zeophlite wants to merge 10 commits into
Open
Conversation
411e873 to
475796e
Compare
Contributor
|
You added a new example but didn't add metadata for it. Please update the root Cargo.toml file. |
cebeed8 to
cffe2f2
Compare
ExtractComponentPlugin etc. to specify AppLabel
ExtractComponentPlugin etc. to specify AppLabelExtractComponentPlugin etc. generic on AppLabel
Zeophlite
added a commit
to Zeophlite/bevy
that referenced
this pull request
Jul 7, 2026
…ExtractComponent` / `ExtractResource` (bevyengine#24420) # Objective - Bevy's extraction process is implicitly for copying data from the main sub-app to the `RenderApp` sub-app - There is two user facing ways to set a component as extractable from the main world to the render world, `#[derive(ExtractComponent)]` (this is preferential) , or `impl ExtractComponent for Foo {}` (similarly for `ExtractResource` and `SyncComponent` ) . - To make extraction possible to different sub-apps, we need to mark all these as explicitly for `RenderApp` - Step towards making the extract infra is reusable for non-rendering crates (see bevyengine#24483 ) ## Solution - Allow `ExtractComponent` , `ExtractResource` and `SyncComponent` to specify the `AppLabel` the trait is implemented for. The corresponding plugin is only implemented for `RenderApp` . - For each explicit `impl`, specify `RenderApp` , e.g. `impl ExtractComponent<RenderApp> for Foo {}` - For each derive `ExtractComponent` and `ExtractResource` , specify the `AppLabel` with the attribute `#[extract_app(RenderApp)]` - This PR has no functionality change, that comes in the followup PRs (see above issue, next PR is bevyengine#24423 ) ## Reviewer Notes Wow 64 files changed! But it's really just 7 files, the rest is mechanical - [_release-content/migration-guides/extract-extract-b.md](https://github.com/bevyengine/bevy/pull/24420/changes#diff-29ebde0ac49075715530302b4377b886582935440e61b0bd434fb17a8a5993f4) - summarises the changes in the rest of the files - [crates/bevy_render/macros/src/extract_component.rs](https://github.com/bevyengine/bevy/pull/24420/changes#diff-5bc5fa18031ec9205350ff74096045895df0dd4767143ba9af86278015124e33) - changes to `derive(ExtractComponent)` - [crates/bevy_render/macros/src/extract_resource.rs](https://github.com/bevyengine/bevy/pull/24420/changes#diff-2677783e1ce394eef4f3c01ceab81dccbe63ecf2637dc7c889afb44fe51f931c) - changes to `derive(ExtractResource)` - [crates/bevy_render/macros/src/lib.rs](https://github.com/bevyengine/bevy/pull/24420/changes#diff-32a45af239b400c46709759c47ba8cacd1e9d0c8baa374aab24e4b05a976413e) - changes to macro call sites - [crates/bevy_render/src/extract_component.rs](https://github.com/bevyengine/bevy/pull/24420/changes#diff-5ba2e960dccc637f00ad81decfa72dff06e9d54fbd9dcffd0750b2fb9349555f) - changes to `ExtractComponent` trait - [crates/bevy_render/src/extract_resource.rs](https://github.com/bevyengine/bevy/pull/24420/changes#diff-12bf0dc2dfa36f71e5222de770bbf3c8ab9f04fe6581d2c76e12842abcc0a1c5) - changes to `ExtractResource` trait - [crates/bevy_render/src/sync_component.rs](https://github.com/bevyengine/bevy/pull/24420/changes#diff-e86373d51ea0dc296bf1b3db6584aaa1c53baadbae3a34f47082bc4ad9f89777) - changes to `SyncComponent` trait I suggest first reading the `ExtractResource` changes as a starting point ## Testing - CI - `cargo run --example animated_mesh` - Follow up PRs (see tracking issue) extend this all the way to multiple extraction --------- Co-authored-by: atlas <email@atlasdostal.com> Co-authored-by: Kevin Chen <chen.kevin.f@gmail.com>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
RenderAppsub-appbevy_extracttracking #24483 )e.g.
Solution
Followed by final PR in tracking issue is #22852 , which moves extraction to a new crate - as such, this PR retains "render" specific language where it was too awkward to change
Please review commit-by-commit
DefaulttoAppLabel'sSyncToRenderWorld = SyncToSubWorld<RenderApp>andRenderEntity = SubEntity<RenderApp>entity_sync_systemto useAppLabel(ExtractPluginspecifiesentity_sync_system::<RenderApp>)ExtractInstanceto be explicit forRenderApp. UpdateExtractInstancesPluginto be generic onAppLabelExtractComponentPluginto be generic onL : AppLabel = RenderApp- in followup PR we will remove this default.ExtractResourcePluginandSyncComponentPlugin.SyncWorldPluginto be generic onAppLabel.ExtractPluginto be generic onAppLabel.RenderPluginto specifyExtractPlugin<RenderApp>.SyncComponentPluginto use an observer, rather than hook#[extract_app(AppA,AppB)]inderive(ExtractComponent)Simplified by #23377
Testing
cargo run --example animated_mesh