Skip to content

Conversation

@djeedai
Copy link
Contributor

@djeedai djeedai commented Dec 17, 2024

Objective

Fixes #16850

Solution

Add a new function SubApp::take_extract(), similar to Option::take(), which allows stealing the currently installed extract function of a sub-app, with the intent to replace it with a custom one calling the original one via set_extract().

This pattern enables registering a custom "world sync" function similar to the existing one entity_sync_system(), to run custom world sync logic with mutable access to both the main and render worlds.

Testing

cargo r -p ci currently doesn't build locally, event after upgrading rustc to latest and doing a cargo update.

Add a new function `SubApp::take_extract()`, similar to
`Option::take()`, which allows stealing the currently installed extract
function of a sub-app, with the intent to replace it with a custom one
calling the original one via `set_extract()`.

This pattern enables registering a custom "world sync" function similar
to the existing one `entity_sync_system()`, to run custom world sync
logic with mutable access to both the main and render worlds.

Fixes bevyengine#16850
@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Dec 17, 2024
@alice-i-cecile alice-i-cecile added this to the 0.15.1 milestone Dec 17, 2024
@alice-i-cecile
Copy link
Member

cargo r -p ci currently doesn't build locally, event after upgrading rustc to latest and doing a cargo update.

Hmm, that's suspicious. @BD103, any ideas?

@djeedai
Copy link
Contributor Author

djeedai commented Dec 17, 2024

cargo r -p ci

error: constant `CURRENT_SCENE` is never used
   --> examples/testbed/3d.rs:147:11
    |
147 |     const CURRENT_SCENE: super::Scene = super::Scene::Bloom;
    |           ^^^^^^^^^^^^^
    |
    = note: `-D dead-code` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(dead_code)]`

error: function `setup` is never used
   --> examples/testbed/3d.rs:149:12
    |
149 |     pub fn setup(
    |            ^^^^^

error: constant `CURRENT_SCENE` is never used
   --> examples/testbed/3d.rs:197:11
    |
197 |     const CURRENT_SCENE: super::Scene = super::Scene::Gltf;
    |           ^^^^^^^^^^^^^

error: function `setup` is never used
   --> examples/testbed/3d.rs:199:12
    |
199 |     pub fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
    |            ^^^^^

error: could not compile `bevy` (example "testbed_3d") due to 4 previous errors

@alice-i-cecile
Copy link
Member

That will be fixed by #16866.

@djeedai
Copy link
Contributor Author

djeedai commented Dec 17, 2024

Note that local CI (cargo r -p ci) still fails because it seems to run docs in stable but uses attributes of nightly:

error[E0554]: `#![feature]` may not be used on the stable release channel
 --> src\lib.rs:2:21
  |
2 | #![cfg_attr(docsrs, feature(doc_auto_cfg))]
  |   

Copy link
Contributor

@hymm hymm left a comment

Choose a reason for hiding this comment

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

Seems like a reasonable way of doing this without having to know what the underlying sub app is doing.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Dec 24, 2024
@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Dec 24, 2024
Merged via the queue into bevyengine:main with commit f9c8f51 Dec 24, 2024
30 checks passed
pcwalton pushed a commit to pcwalton/bevy that referenced this pull request Dec 25, 2024
# Objective

Fixes bevyengine#16850

## Solution

Add a new function `SubApp::take_extract()`, similar to
`Option::take()`, which allows stealing the currently installed extract
function of a sub-app, with the intent to replace it with a custom one
calling the original one via `set_extract()`.

This pattern enables registering a custom "world sync" function similar
to the existing one `entity_sync_system()`, to run custom world sync
logic with mutable access to both the main and render worlds.

## Testing

`cargo r -p ci` currently doesn't build locally, event after upgrading
rustc to latest and doing a `cargo update`.
mockersf pushed a commit that referenced this pull request Jan 3, 2025
# Objective

Fixes #16850

## Solution

Add a new function `SubApp::take_extract()`, similar to
`Option::take()`, which allows stealing the currently installed extract
function of a sub-app, with the intent to replace it with a custom one
calling the original one via `set_extract()`.

This pattern enables registering a custom "world sync" function similar
to the existing one `entity_sync_system()`, to run custom world sync
logic with mutable access to both the main and render worlds.

## Testing

`cargo r -p ci` currently doesn't build locally, event after upgrading
rustc to latest and doing a `cargo update`.
ecoskey pushed a commit to ecoskey/bevy that referenced this pull request Jan 6, 2025
# Objective

Fixes bevyengine#16850

## Solution

Add a new function `SubApp::take_extract()`, similar to
`Option::take()`, which allows stealing the currently installed extract
function of a sub-app, with the intent to replace it with a custom one
calling the original one via `set_extract()`.

This pattern enables registering a custom "world sync" function similar
to the existing one `entity_sync_system()`, to run custom world sync
logic with mutable access to both the main and render worlds.

## Testing

`cargo r -p ci` currently doesn't build locally, event after upgrading
rustc to latest and doing a `cargo update`.
mrchantey pushed a commit to mrchantey/bevy that referenced this pull request Feb 4, 2025
# Objective

Fixes bevyengine#16850

## Solution

Add a new function `SubApp::take_extract()`, similar to
`Option::take()`, which allows stealing the currently installed extract
function of a sub-app, with the intent to replace it with a custom one
calling the original one via `set_extract()`.

This pattern enables registering a custom "world sync" function similar
to the existing one `entity_sync_system()`, to run custom world sync
logic with mutable access to both the main and render worlds.

## Testing

`cargo r -p ci` currently doesn't build locally, event after upgrading
rustc to latest and doing a `cargo update`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Manually insert RenderEntity / reverse extract

3 participants