From 87e48e3043398d1763cfe9e2351b22cbd4a47272 Mon Sep 17 00:00:00 2001 From: Viktor Gustavsson Date: Mon, 10 Feb 2025 19:31:56 +0100 Subject: [PATCH 1/3] Migrate everything except bevy_editor_cam --- Cargo.toml | 8 ++-- .../bevy_asset_browser/src/ui/top_bar.rs | 4 +- .../src/hierarchy.rs | 4 +- crates/bevy_bsn/src/construct.rs | 38 +++++++++---------- crates/bevy_infinite_grid/src/render/mod.rs | 4 +- crates/bevy_pane_layout/src/handlers.rs | 10 +---- crates/bevy_pane_layout/src/lib.rs | 6 +-- crates/bevy_pane_layout/src/ui.rs | 10 +---- 8 files changed, 36 insertions(+), 48 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ed1e4f3..e0a75f5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,12 +27,12 @@ unsafe_op_in_unsafe_fn = "warn" unused_qualifications = "warn" [workspace.dependencies] -bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "909b02e9de418fcf3b8960e98c3de423505eadd5", features = [ +bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "232824c009c38ee26ad308f054bc12888f0020e9", features = [ "wayland", ] } -bevy_derive = { git = "https://github.com/bevyengine/bevy.git", rev = "909b02e9de418fcf3b8960e98c3de423505eadd5" } -bevy_macro_utils = { git = "https://github.com/bevyengine/bevy.git", rev = "909b02e9de418fcf3b8960e98c3de423505eadd5" } -thiserror = "1" +bevy_derive = { git = "https://github.com/bevyengine/bevy.git", rev = "232824c009c38ee26ad308f054bc12888f0020e9" } +bevy_macro_utils = { git = "https://github.com/bevyengine/bevy.git", rev = "232824c009c38ee26ad308f054bc12888f0020e9" } +thiserror = "2.0" serde = { version = "1", features = ["derive"] } tracing-test = "0.2.5" tracing = "0.1.40" diff --git a/bevy_editor_panes/bevy_asset_browser/src/ui/top_bar.rs b/bevy_editor_panes/bevy_asset_browser/src/ui/top_bar.rs index 6751b6f..bca12a1 100644 --- a/bevy_editor_panes/bevy_asset_browser/src/ui/top_bar.rs +++ b/bevy_editor_panes/bevy_asset_browser/src/ui/top_bar.rs @@ -52,7 +52,7 @@ pub fn refresh_ui( // Clear location path UI if let Some(childrens) = top_bar_childrens { for child in childrens.iter() { - commands.entity(*child).despawn(); + commands.entity(child).despawn(); } commands.entity(top_bar_entity).remove::(); } @@ -169,7 +169,7 @@ fn spawn_path_segment_ui<'a>( .iter() .step_by(2) // Step by 2 to go through each segment, skipping the separators .skip(1) // Skip the "Sources" segment - .position(|child| *child == segment) + .position(|child| child == segment) .expect( "You shouldn't be able to click on a segment that isn't in the asset location path" ); diff --git a/bevy_widgets/bevy_i-cant-believe-its-not-bsn/src/hierarchy.rs b/bevy_widgets/bevy_i-cant-believe-its-not-bsn/src/hierarchy.rs index 36cb70b..8ec87a3 100644 --- a/bevy_widgets/bevy_i-cant-believe-its-not-bsn/src/hierarchy.rs +++ b/bevy_widgets/bevy_i-cant-believe-its-not-bsn/src/hierarchy.rs @@ -256,7 +256,7 @@ mod tests { assert_eq!(children.len(), 3); for (i, child_entity) in children.iter().enumerate() { - assert_eq!(world.get::(*child_entity), Some(&B(i as u8))); + assert_eq!(world.get::(child_entity), Some(&B(i as u8))); } } @@ -275,7 +275,7 @@ mod tests { assert_eq!(children.len(), 7); for (i, child_entity) in children.iter().enumerate() { - assert_eq!(world.get::(*child_entity), Some(&B(i as u8))); + assert_eq!(world.get::(child_entity), Some(&B(i as u8))); } } diff --git a/crates/bevy_bsn/src/construct.rs b/crates/bevy_bsn/src/construct.rs index 63d2f3b..3ade192 100644 --- a/crates/bevy_bsn/src/construct.rs +++ b/crates/bevy_bsn/src/construct.rs @@ -1,9 +1,8 @@ use alloc::borrow::Cow; use bevy::{ ecs::{ - bundle::DynamicBundle, + bundle::{BundleFromComponents, DynamicBundle}, component::{ComponentId, Components, RequiredComponents, StorageType}, - storage::Storages, system::EntityCommands, world::error::EntityFetchError, }, @@ -186,16 +185,27 @@ all_tuples!( ); #[allow(unsafe_code)] -/// SAFETY: This just passes through to the inner [`Bundle`] implementations. +/// SAFETY: This just passes through to the inner [`Bundle`] implementation. unsafe impl Bundle for ConstructTuple { - fn component_ids( + fn component_ids(components: &mut Components, ids: &mut impl FnMut(ComponentId)) { + B::component_ids(components, ids); + } + + fn register_required_components( components: &mut Components, - storages: &mut Storages, - ids: &mut impl FnMut(ComponentId), + required_components: &mut RequiredComponents, ) { - B::component_ids(components, storages, ids); + B::register_required_components(components, required_components); } + fn get_component_ids(components: &Components, ids: &mut impl FnMut(Option)) { + B::get_component_ids(components, ids); + } +} + +#[allow(unsafe_code)] +/// SAFETY: This just passes through to the inner [`BundleFromComponents`] implementation. +unsafe impl BundleFromComponents for ConstructTuple { unsafe fn from_components(ctx: &mut T, func: &mut F) -> Self where // Ensure that the `OwningPtr` is used correctly @@ -207,21 +217,11 @@ unsafe impl Bundle for ConstructTuple { unsafe { B::from_components(ctx, func) }, ) } - - fn register_required_components( - components: &mut Components, - storages: &mut Storages, - required_components: &mut RequiredComponents, - ) { - B::register_required_components(components, storages, required_components); - } - - fn get_component_ids(components: &Components, ids: &mut impl FnMut(Option)) { - B::get_component_ids(components, ids); - } } impl DynamicBundle for ConstructTuple { + type Effect = (); + fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>)) { self.0.get_components(func); } diff --git a/crates/bevy_infinite_grid/src/render/mod.rs b/crates/bevy_infinite_grid/src/render/mod.rs index 6bfc0b0..1cbe10c 100755 --- a/crates/bevy_infinite_grid/src/render/mod.rs +++ b/crates/bevy_infinite_grid/src/render/mod.rs @@ -1,7 +1,7 @@ use std::borrow::Cow; use bevy::{ - asset::load_internal_asset, + asset::{load_internal_asset, weak_handle}, core_pipeline::{core_2d::Transparent2d, core_3d::Transparent3d}, ecs::{ query::ROQueryItem, @@ -37,7 +37,7 @@ use bevy::{ use crate::InfiniteGridSettings; -const GRID_SHADER_HANDLE: Handle = Handle::weak_from_u128(15204473893972682982); +const GRID_SHADER_HANDLE: Handle = weak_handle!("7cd38dd1-d707-481e-b38c-0eccb706e629"); pub fn render_app_builder(app: &mut App) { load_internal_asset!(app, GRID_SHADER_HANDLE, "grid.wgsl", Shader::from_wgsl); diff --git a/crates/bevy_pane_layout/src/handlers.rs b/crates/bevy_pane_layout/src/handlers.rs index 43bbd6a..5906053 100644 --- a/crates/bevy_pane_layout/src/handlers.rs +++ b/crates/bevy_pane_layout/src/handlers.rs @@ -26,10 +26,7 @@ pub(crate) fn remove_pane( // Find the index of this pane among its siblings let siblings = children_query.get(parent).unwrap(); - let index = siblings - .iter() - .position(|entity| *entity == target) - .unwrap(); + let index = siblings.iter().position(|entity| entity == target).unwrap(); let size = size_query.get(target).unwrap().0; @@ -84,10 +81,7 @@ pub(crate) fn split_pane( // Find the index of this pane among its siblings let siblings = children_query.get(parent).unwrap(); - let index = siblings - .iter() - .position(|entity| *entity == target) - .unwrap(); + let index = siblings.iter().position(|entity| entity == target).unwrap(); // Parent has a matching divider direction let matching_direction = divider_query diff --git a/crates/bevy_pane_layout/src/lib.rs b/crates/bevy_pane_layout/src/lib.rs index a044844..f5493b2 100644 --- a/crates/bevy_pane_layout/src/lib.rs +++ b/crates/bevy_pane_layout/src/lib.rs @@ -142,8 +142,8 @@ fn cleanup_divider_single_child( for (entity, children, parent) in &mut query { let mut iter = children .iter() - .filter(|child| !resize_handle_query.contains(**child)); - let child = *iter.next().unwrap(); + .filter(|child| !resize_handle_query.contains(*child)); + let child = iter.next().unwrap(); if iter.next().is_some() { continue; } @@ -153,7 +153,7 @@ fn cleanup_divider_single_child( // Find the index of this divider among its siblings let siblings = children_query.get(parent.get()).unwrap(); - let index = siblings.iter().position(|s| *s == entity).unwrap(); + let index = siblings.iter().position(|s| s == entity).unwrap(); commands .entity(parent.get()) diff --git a/crates/bevy_pane_layout/src/ui.rs b/crates/bevy_pane_layout/src/ui.rs index 2fb00df..d3e2e3d 100644 --- a/crates/bevy_pane_layout/src/ui.rs +++ b/crates/bevy_pane_layout/src/ui.rs @@ -223,10 +223,7 @@ pub(crate) fn spawn_resize_handle<'a>( let siblings = children_query.get(parent).unwrap(); // Find the index of this handle among its siblings - let index = siblings - .iter() - .position(|entity| *entity == target) - .unwrap(); + let index = siblings.iter().position(|entity| entity == target).unwrap(); let size_a = size_query.get(siblings[index - 1]).unwrap().0; let size_b = size_query.get(siblings[index + 1]).unwrap().0; @@ -252,10 +249,7 @@ pub(crate) fn spawn_resize_handle<'a>( let parent = parent_query.get(target).unwrap().get(); let siblings = children_query.get(parent).unwrap(); // Find the index of this handle among its siblings - let index = siblings - .iter() - .position(|entity| *entity == target) - .unwrap(); + let index = siblings.iter().position(|entity| entity == target).unwrap(); let delta = trigger.event().delta; let delta = match divider_parent { From cb833a1800c7a02304e816e499ee81c3bdd9f4ed Mon Sep 17 00:00:00 2001 From: Viktor Gustavsson Date: Tue, 11 Feb 2025 22:41:58 +0100 Subject: [PATCH 2/3] Update bevy to d6725d3 and migrate PointerAction --- Cargo.toml | 6 +++--- crates/bevy_editor_cam/src/input.rs | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e0a75f5..a237d14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,11 +27,11 @@ unsafe_op_in_unsafe_fn = "warn" unused_qualifications = "warn" [workspace.dependencies] -bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "232824c009c38ee26ad308f054bc12888f0020e9", features = [ +bevy = { git = "https://github.com/bevyengine/bevy.git", rev = "d6725d3b1baa6a730fa6bfab1bb8f2a9e5f4716e", features = [ "wayland", ] } -bevy_derive = { git = "https://github.com/bevyengine/bevy.git", rev = "232824c009c38ee26ad308f054bc12888f0020e9" } -bevy_macro_utils = { git = "https://github.com/bevyengine/bevy.git", rev = "232824c009c38ee26ad308f054bc12888f0020e9" } +bevy_derive = { git = "https://github.com/bevyengine/bevy.git", rev = "d6725d3b1baa6a730fa6bfab1bb8f2a9e5f4716e" } +bevy_macro_utils = { git = "https://github.com/bevyengine/bevy.git", rev = "d6725d3b1baa6a730fa6bfab1bb8f2a9e5f4716e" } thiserror = "2.0" serde = { version = "1", features = ["derive"] } tracing-test = "0.2.5" diff --git a/crates/bevy_editor_cam/src/input.rs b/crates/bevy_editor_cam/src/input.rs index 0ccb280..d459bdd 100644 --- a/crates/bevy_editor_cam/src/input.rs +++ b/crates/bevy_editor_cam/src/input.rs @@ -286,7 +286,8 @@ impl EditorCamInputEvent { PointerAction::Move { delta } => Some(delta), PointerAction::Press { .. } | PointerAction::Cancel - | PointerAction::Release(_) => None, + | PointerAction::Release(_) + | PointerAction::Scroll { .. } => None, }) .sum(); From 7de227cef3cfb463958435b606197138095721ac Mon Sep 17 00:00:00 2001 From: Viktor Gustavsson Date: Tue, 11 Feb 2025 22:56:22 +0100 Subject: [PATCH 3/3] Add workaround for ashpd not explicitly depending on futures-util/io --- Cargo.toml | 4 ++++ crates/bevy_editor/Cargo.toml | 1 + crates/bevy_editor_launcher/Cargo.toml | 1 + 3 files changed, 6 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index a237d14..a008028 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,6 +41,10 @@ rfd = "0.15" ron = "0.8.1" variadics_please = "1.0" +# This is a temporary workaround for https://github.com/bilelmoussaoui/ashpd/issues/264 +# Should be ok to remove once the issue is fixed, published, and `rfd` points to the new version. +futures-util = { version = "0.3", features = ["io"] } + # local crates # bevy_editor_panes diff --git a/crates/bevy_editor/Cargo.toml b/crates/bevy_editor/Cargo.toml index b4f863e..ac51f96 100644 --- a/crates/bevy_editor/Cargo.toml +++ b/crates/bevy_editor/Cargo.toml @@ -14,6 +14,7 @@ bevy_editor_styles.workspace = true serde.workspace = true ron.workspace = true rfd.workspace = true +futures-util.workspace = true # Panes bevy_editor_core.workspace = true diff --git a/crates/bevy_editor_launcher/Cargo.toml b/crates/bevy_editor_launcher/Cargo.toml index 34f8116..f49a04b 100644 --- a/crates/bevy_editor_launcher/Cargo.toml +++ b/crates/bevy_editor_launcher/Cargo.toml @@ -14,5 +14,6 @@ bevy_footer_bar.workspace = true bevy_editor_styles.workspace = true rfd.workspace = true +futures-util.workspace = true serde.workspace = true ron.workspace = true