From 2837eb3e945395325d1a594e5052f3b904b400e2 Mon Sep 17 00:00:00 2001 From: Patrick Dobbs Date: Thu, 28 Nov 2024 13:26:07 +0000 Subject: [PATCH] Update to Bevy 0.15 --- Cargo.toml | 12 ++++++--- README.md | 1 + examples/basic.rs | 2 +- examples/cycle.rs | 56 ++++++++++++++++++----------------------- examples/detection.rs | 2 +- examples/gradient.rs | 2 +- examples/models.rs | 2 +- examples/nishita.rs | 2 +- examples/settings.rs | 2 +- examples/splitscreen.rs | 54 ++++++++++++++++++--------------------- macros/Cargo.toml | 4 +-- src/lib.rs | 2 +- src/plugin.rs | 14 ++++------- 13 files changed, 71 insertions(+), 84 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a46983d..3528af2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,17 +11,17 @@ repository = "https://github.com/JonahPlusPlus/bevy_atmosphere" exclude = ["/assets/", "/examples/", "/.github/"] [dependencies] -bevy = { version = "0.14", default-features = false, features = [ +bevy = { version = "0.15.0-rc.3", default-features = false, features = [ "bevy_asset", "bevy_render", "bevy_pbr", ] } -bevy_atmosphere_macros = { path = "macros", version = "0.6" } +bevy_atmosphere_macros = { path = "macros", version = "0.7" } cfg-if = "1.0" [dev-dependencies] -bevy_spectator = "0.6" -bevy = { version = "0.14", features = ["bevy_core_pipeline", "x11"] } +bevy_spectator = "0.7" +bevy = { version = "0.15.0-rc.3", features = ["bevy_core_pipeline", "x11"] } [features] default = ["basic", "all_models"] @@ -74,3 +74,7 @@ required-features = ["default"] name = "splitscreen" path = "examples/splitscreen.rs" required-features = ["default"] + +[patch.crates-io] +# TODO: Temporary patch for dev-dep, remove when upstream updates +bevy_spectator = { git = "https://github.com/ptsd/bevy_spectator.git", branch = "bevy-0.15" } diff --git a/README.md b/README.md index a8d4215..72e309d 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ For more information on the technicalities, you can check out the [technical doc | bevy | bevy_atmosphere | |------|-----------------| +| 0.15 | 0.11 | | 0.14 | 0.10 | | 0.13 | 0.9 | | 0.12 | 0.8 | diff --git a/examples/basic.rs b/examples/basic.rs index 32999fe..6028b18 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -10,5 +10,5 @@ fn main() { } fn setup(mut commands: Commands) { - commands.spawn((Camera3dBundle::default(), AtmosphereCamera::default())); + commands.spawn((Camera3d::default(), AtmosphereCamera::default())); } diff --git a/examples/cycle.rs b/examples/cycle.rs index c93449f..ad7b328 100644 --- a/examples/cycle.rs +++ b/examples/cycle.rs @@ -4,7 +4,6 @@ use bevy_spectator::{Spectator, SpectatorPlugin}; fn main() { App::new() - .insert_resource(Msaa::Sample4) .insert_resource(AtmosphereModel::default()) // Default Atmosphere material, we can edit it to simulate another planet .insert_resource(CycleTimer(Timer::new( bevy::utils::Duration::from_millis(50), // Update our atmosphere every 50ms (in a real game, this would be much slower, but for the sake of an example we use a faster update) @@ -38,7 +37,7 @@ fn daylight_cycle( timer.0.tick(time.delta()); if timer.0.finished() { - let t = time.elapsed_seconds_wrapped() / 2.0; + let t = time.elapsed_secs_wrapped() / 2.0; atmosphere.sun_position = Vec3::new(0., t.sin(), t.cos()); if let Some((mut light_trans, mut directional)) = query.single_mut().into() { @@ -56,49 +55,42 @@ fn setup_environment( ) { // Our Sun commands.spawn(( - DirectionalLightBundle { - ..Default::default() - }, + DirectionalLight::default(), Sun, // Marks the light as Sun )); // Simple transform shape just for reference - commands.spawn(PbrBundle { - mesh: meshes.add(Cuboid::default()), - material: materials.add(StandardMaterial::from(Color::srgb(0.8, 0.8, 0.8))), - ..Default::default() - }); + commands.spawn(( + Mesh3d(meshes.add(Cuboid::default())), + MeshMaterial3d(materials.add(StandardMaterial::from(Color::srgb(0.8, 0.8, 0.8)))), + )); // X axis - commands.spawn(PbrBundle { - mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)), - material: materials.add(StandardMaterial::from(Color::srgb(0.8, 0.0, 0.0))), - transform: Transform::from_xyz(1., 0., 0.), - ..Default::default() - }); + commands.spawn(( + Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))), + MeshMaterial3d(materials.add(StandardMaterial::from(Color::srgb(0.8, 0.0, 0.0)))), + Transform::from_xyz(1., 0., 0.), + )); // Y axis - commands.spawn(PbrBundle { - mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)), - material: materials.add(StandardMaterial::from(Color::srgb(0.0, 0.8, 0.0))), - transform: Transform::from_xyz(0., 1., 0.), - ..Default::default() - }); + commands.spawn(( + Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))), + MeshMaterial3d(materials.add(StandardMaterial::from(Color::srgb(0.0, 0.8, 0.0)))), + Transform::from_xyz(0., 1., 0.), + )); // Z axis - commands.spawn(PbrBundle { - mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)), - material: materials.add(StandardMaterial::from(Color::srgb(0.0, 0.0, 0.8))), - transform: Transform::from_xyz(0., 0., 1.), - ..Default::default() - }); + commands.spawn(( + Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))), + MeshMaterial3d(materials.add(StandardMaterial::from(Color::srgb(0.0, 0.0, 0.8)))), + Transform::from_xyz(0., 0., 1.), + )); // Spawn our camera commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(5., 0., 5.), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(5., 0., 5.), + Msaa::Sample4, AtmosphereCamera::default(), // Marks camera as having a skybox, by default it doesn't specify the render layers the skybox can be seen on Spectator, // Marks camera as spectator (specific to bevy_spectator) )); diff --git a/examples/detection.rs b/examples/detection.rs index 18b858c..f9d076a 100644 --- a/examples/detection.rs +++ b/examples/detection.rs @@ -14,7 +14,7 @@ fn main() { struct PrimaryCamera; fn setup(mut commands: Commands) { - commands.spawn((Camera3dBundle::default(), PrimaryCamera)); + commands.spawn((Camera3d::default(), PrimaryCamera)); } fn update( diff --git a/examples/gradient.rs b/examples/gradient.rs index 6b6ba34..5debb9e 100644 --- a/examples/gradient.rs +++ b/examples/gradient.rs @@ -15,7 +15,7 @@ fn main() { fn setup(mut commands: Commands) { commands.spawn(( - Camera3dBundle::default(), + Camera3d::default(), AtmosphereCamera::default(), Spectator, )); diff --git a/examples/models.rs b/examples/models.rs index 6ec35d1..f43930e 100644 --- a/examples/models.rs +++ b/examples/models.rs @@ -14,7 +14,7 @@ fn main() { fn setup(mut commands: Commands) { commands.spawn(( - Camera3dBundle::default(), + Camera3d::default(), AtmosphereCamera::default(), Spectator, )); diff --git a/examples/nishita.rs b/examples/nishita.rs index eb41bdb..e64888b 100644 --- a/examples/nishita.rs +++ b/examples/nishita.rs @@ -13,7 +13,7 @@ fn main() { fn setup(mut commands: Commands) { commands.spawn(( - Camera3dBundle::default(), + Camera3d::default(), AtmosphereCamera::default(), Spectator, )); diff --git a/examples/settings.rs b/examples/settings.rs index 36e049b..f57db82 100644 --- a/examples/settings.rs +++ b/examples/settings.rs @@ -17,7 +17,7 @@ fn main() { fn setup(mut commands: Commands) { commands.spawn(( - Camera3dBundle::default(), + Camera3d::default(), AtmosphereCamera::default(), Spectator, )); diff --git a/examples/splitscreen.rs b/examples/splitscreen.rs index 052c412..ed5de38 100644 --- a/examples/splitscreen.rs +++ b/examples/splitscreen.rs @@ -12,7 +12,6 @@ use bevy_spectator::{Spectator, SpectatorPlugin, SpectatorSettings}; fn main() { println!("Demonstrates using `AtmosphereCamera.render_layers` to have multiple skyboxes in the scene at once\n\t- E: Switch camera"); App::new() - .insert_resource(Msaa::Sample4) .insert_resource(AtmosphereModel::new(Nishita { rayleigh_coefficient: Vec3::new(22.4e-6, 5.5e-6, 13.0e-6), // Change rayleigh coefficient to change color ..default() @@ -36,34 +35,31 @@ fn setup( mut settings: ResMut, ) { // Plane - commands.spawn(PbrBundle { - mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)), - material: materials.add(Color::srgb(0.3, 0.5, 0.3)), - ..default() - }); + commands.spawn(( + Mesh3d(meshes.add(Plane3d::default().mesh().size(100.0, 100.0))), + MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))), + )); // Light - commands.spawn(DirectionalLightBundle { - transform: Transform::from_rotation(Quat::from_euler( + commands.spawn(( + DirectionalLight { + shadows_enabled: true, + ..default() + }, + Transform::from_rotation(Quat::from_euler( EulerRot::ZYX, 0.0, 1.0, -std::f32::consts::FRAC_PI_4, - )), - directional_light: DirectionalLight { - shadows_enabled: true, - ..default() - }, - ..default() - }); + )) + )); // Spawn left screen camera and make it the default spectator let left = commands .spawn(( - Camera3dBundle { - transform: Transform::from_xyz(0.0, 25.0, -100.0).looking_at(Vec3::ZERO, Vec3::Y), - ..default() - }, + Camera3d::default(), + Transform::from_xyz(0.0, 25.0, -100.0).looking_at(Vec3::ZERO, Vec3::Y), + Msaa::Sample4, RenderLayers::from_layers(&[0, 1]), // To prevent each player from seeing the other skybox, we put each one on a separate render layer (you could also use this render layer for other player specific effects) AtmosphereCamera { render_layers: Some(RenderLayers::layer(1)), @@ -77,19 +73,17 @@ fn setup( // Spawn right screen camera commands.spawn(( - Camera3dBundle { - transform: Transform::from_xyz(100.0, 50.0, 150.0).looking_at(Vec3::ZERO, Vec3::Y), - camera: Camera { - // Renders the right camera after the left camera, which has a default priority of 0 - order: 1, - // Don't clear on the second camera because the first camera already cleared the window - clear_color: ClearColorConfig::None, - ..default() - }, - camera_3d: Camera3d::default(), + Camera { + // Renders the right camera after the left camera, which has a default priority of 0 + order: 1, + // Don't clear on the second camera because the first camera already cleared the window + clear_color: ClearColorConfig::None, ..default() }, - RenderLayers::from_layers(&[0, 2]), + Camera3d::default(), + Transform::from_xyz(100.0, 50.0, 150.0).looking_at(Vec3::ZERO, Vec3::Y), + Msaa::Sample4, + RenderLayers::from_layers(&[0, 2]), // To prevent each player from seeing the other skybox, we put each one on a separate render layer (you could also use this render layer for other player specific effects) AtmosphereCamera { render_layers: Some(RenderLayers::layer(2)), }, diff --git a/macros/Cargo.toml b/macros/Cargo.toml index a900cab..c3f7e05 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "bevy_atmosphere_macros" description = "Proc macros for bevy_atmosphere" -version = "0.6.0" +version = "0.7.0" edition = "2021" authors = ["JonahPlusPlus <33059163+JonahPlusPlus@users.noreply.github.com>"] license = "MIT OR Apache-2.0" @@ -15,7 +15,7 @@ proc-macro = true [dependencies] proc-macro-crate = "3.1" -bevy_macro_utils = "0.14" +bevy_macro_utils = "0.15.0-rc.3" syn = "2.0" proc-macro2 = "1.0" diff --git a/src/lib.rs b/src/lib.rs index b5e249a..8962e95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,7 +16,7 @@ //! } //! //! fn setup(mut commands: Commands) { -//! commands.spawn((Camera3dBundle::default(), AtmosphereCamera::default())); +//! commands.spawn((Camera3d::default(), AtmosphereCamera::default())); //! } //! ``` //! diff --git a/src/plugin.rs b/src/plugin.rs index 0e07260..f53b2c5 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -109,17 +109,13 @@ fn atmosphere_insert( trace!("Adding skybox to camera entity (ID:{:?})", camera); commands .entity(camera) - .insert(VisibilityBundle { - visibility: Visibility::Visible, - ..default() - }) + .insert(( + Visibility::Visible, + )) .with_children(|c| { let mut child = c.spawn(( - MaterialMeshBundle { - mesh: mesh_assets.add(crate::skybox::mesh(projection.far())), - material: material.0.clone(), - ..default() - }, + Mesh3d(mesh_assets.add(crate::skybox::mesh(projection.far()))), + MeshMaterial3d(material.0.clone()), AtmosphereSkyBox, NotShadowCaster, NotShadowReceiver,