From 56fd79a820c8b272dc7fe1bf87fb98740d04c512 Mon Sep 17 00:00:00 2001 From: Huon Imberger Date: Fri, 5 Jul 2024 19:06:47 +1000 Subject: [PATCH] Update to Bevy 0.14 --- Cargo.toml | 6 +++--- examples/advanced.rs | 4 ++-- examples/basic.rs | 4 ++-- src/controller.rs | 4 ++-- src/lib.rs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 588f2f4..fe6982b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,8 @@ readme = "README.md" exclude = ["assets/"] [dependencies] -bevy = { version = "0.13", default-features = false, features = ["bevy_render"] } -bevy_mod_raycast = { version = "0.17" } +bevy = { version = "0.14", default-features = false, features = ["bevy_render"] } +bevy_mod_raycast = { version = "0.18" } [dev-dependencies] -bevy = { version = "0.13" } +bevy = { version = "0.14" } diff --git a/examples/advanced.rs b/examples/advanced.rs index 59593ce..773ff24 100644 --- a/examples/advanced.rs +++ b/examples/advanced.rs @@ -33,14 +33,14 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(80.0, 80.0)), - material: materials.add(Color::rgb(0.3, 0.5, 0.3)), + material: materials.add(Color::srgb(0.3, 0.5, 0.3)), ..default() }, // Add `Ground` component to any entity you want the camera to treat as ground. Ground, )); // Some "terrain" - let terrain_material = materials.add(Color::rgb(0.8, 0.7, 0.6)); + let terrain_material = materials.add(Color::srgb(0.8, 0.7, 0.6)); commands.spawn(( PbrBundle { mesh: meshes.add(Cuboid::new(15.0, 1.0, 5.0)), diff --git a/examples/basic.rs b/examples/basic.rs index bba0ab1..8f826ed 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -22,14 +22,14 @@ fn setup( commands.spawn(( PbrBundle { mesh: meshes.add(Plane3d::default().mesh().size(80.0, 80.0)), - material: materials.add(Color::rgb(0.3, 0.5, 0.3)), + material: materials.add(Color::srgb(0.3, 0.5, 0.3)), ..default() }, // Add `Ground` component to any entity you want the camera to treat as ground. Ground, )); // Some "terrain" - let terrain_material = materials.add(Color::rgb(0.8, 0.7, 0.6)); + let terrain_material = materials.add(Color::srgb(0.8, 0.7, 0.6)); commands.spawn(( PbrBundle { mesh: meshes.add(Cuboid::new(15.0, 1.0, 5.0)), diff --git a/src/controller.rs b/src/controller.rs index d503ab5..6aebd1b 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -6,14 +6,14 @@ use bevy::input::ButtonInput; use bevy::prelude::*; use bevy::window::{CursorGrabMode, PrimaryWindow}; use bevy_mod_raycast::immediate::{Raycast, RaycastSettings}; -use bevy_mod_raycast::{CursorRay, DefaultRaycastingPlugin}; +use bevy_mod_raycast::prelude::{CursorRay, CursorRayPlugin}; use std::f32::consts::PI; pub struct RtsCameraControlsPlugin; impl Plugin for RtsCameraControlsPlugin { fn build(&self, app: &mut App) { - app.add_plugins(DefaultRaycastingPlugin).add_systems( + app.add_plugins(CursorRayPlugin).add_systems( Update, (zoom, pan, grab_pan, rotate).before(RtsCameraSystemSet), ); diff --git a/src/lib.rs b/src/lib.rs index 234493e..aab4ee9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -203,7 +203,7 @@ fn follow_ground( cam.target_focus.translation.y + cam.height_max, cam.target_focus.translation.z, ); - if let Some(hit1) = cast_ray(&mut raycast, ray_start, Direction3d::NEG_Y, &|entity| { + if let Some(hit1) = cast_ray(&mut raycast, ray_start, Dir3::NEG_Y, &|entity| { ground_q.get(entity).is_ok() }) { cam.target_focus.translation.y = hit1.position().y; @@ -282,7 +282,7 @@ fn update_camera_transform(mut cam_q: Query<(&mut Transform, &RtsCamera)>) { fn cast_ray<'a>( raycast: &'a mut Raycast<'_, '_>, origin: Vec3, - dir: Direction3d, + dir: Dir3, filter: &'a dyn Fn(Entity) -> bool, ) -> Option<&'a IntersectionData> { let ray1 = Ray3d::new(origin, Vec3::from(dir));