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

Migrate bevy to latest main #178

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "d6725d3b1baa6a730fa6bfab1bb8f2a9e5f4716e", 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 = "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"
tracing = "0.1.40"
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions bevy_editor_panes/bevy_asset_browser/src/ui/top_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Children>();
}
Expand Down Expand Up @@ -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"
);
Expand Down
4 changes: 2 additions & 2 deletions bevy_widgets/bevy_i-cant-believe-its-not-bsn/src/hierarchy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ mod tests {
assert_eq!(children.len(), 3);

for (i, child_entity) in children.iter().enumerate() {
assert_eq!(world.get::<B>(*child_entity), Some(&B(i as u8)));
assert_eq!(world.get::<B>(child_entity), Some(&B(i as u8)));
}
}

Expand All @@ -275,7 +275,7 @@ mod tests {
assert_eq!(children.len(), 7);

for (i, child_entity) in children.iter().enumerate() {
assert_eq!(world.get::<B>(*child_entity), Some(&B(i as u8)));
assert_eq!(world.get::<B>(child_entity), Some(&B(i as u8)));
}
}

Expand Down
38 changes: 19 additions & 19 deletions crates/bevy_bsn/src/construct.rs
Original file line number Diff line number Diff line change
@@ -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,
},
Expand Down Expand Up @@ -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<B: Bundle> Bundle for ConstructTuple<B> {
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<ComponentId>)) {
B::get_component_ids(components, ids);
}
}

#[allow(unsafe_code)]
/// SAFETY: This just passes through to the inner [`BundleFromComponents`] implementation.
unsafe impl<B: BundleFromComponents> BundleFromComponents for ConstructTuple<B> {
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> Self
where
// Ensure that the `OwningPtr` is used correctly
Expand All @@ -207,21 +217,11 @@ unsafe impl<B: Bundle> Bundle for ConstructTuple<B> {
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<ComponentId>)) {
B::get_component_ids(components, ids);
}
}

impl<B: Bundle> DynamicBundle for ConstructTuple<B> {
type Effect = ();

fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>)) {
self.0.get_components(func);
}
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_editor_cam/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ impl EditorCamInputEvent {
PointerAction::Move { delta } => Some(delta),
PointerAction::Press { .. }
| PointerAction::Cancel
| PointerAction::Release(_) => None,
| PointerAction::Release(_)
| PointerAction::Scroll { .. } => None,
})
.sum();

Expand Down
1 change: 1 addition & 0 deletions crates/bevy_editor_launcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions crates/bevy_infinite_grid/src/render/mod.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -37,7 +37,7 @@ use bevy::{

use crate::InfiniteGridSettings;

const GRID_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(15204473893972682982);
const GRID_SHADER_HANDLE: Handle<Shader> = 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);
Expand Down
10 changes: 2 additions & 8 deletions crates/bevy_pane_layout/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_pane_layout/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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())
Expand Down
10 changes: 2 additions & 8 deletions crates/bevy_pane_layout/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down