Skip to content

Commit

Permalink
Update to Bevy 0.15 (#74)
Browse files Browse the repository at this point in the history
Co-authored-by: Hennadii Chernyshchyk <[email protected]>
  • Loading branch information
ptsd and Shatur authored Dec 7, 2024
1 parent 42e3170 commit cf36a87
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 126 deletions.
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ repository = "https://github.com/JonahPlusPlus/bevy_atmosphere"
exclude = ["/assets/", "/examples/", "/.github/"]

[dependencies]
bevy = { version = "0.14", default-features = false, features = [
bevy = { version = "0.15", default-features = false, features = [
"bevy_asset",
"bevy_render",
"bevy_pbr",
"png", # Enable temporary due to 0.15 bug: https://github.com/bevyengine/bevy/issues/16563
] }
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", features = ["bevy_core_pipeline", "x11"] }

[features]
default = ["basic", "all_models"]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
19 changes: 12 additions & 7 deletions deny.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[advisories]
unmaintained = "deny"
yanked = "deny"
notice = "deny"

[licenses]
copyleft = "deny"
allow-osi-fsf-free = "either"
allow = [
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"BSL-1.0",
"CC0-1.0",
"ISC",
"MIT-0",
"MIT",
"Unicode-3.0",
"Zlib",
]

[[licenses.clarify]]
name = "stretch"
Expand Down
2 changes: 1 addition & 1 deletion examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ fn main() {
}

fn setup(mut commands: Commands) {
commands.spawn((Camera3dBundle::default(), AtmosphereCamera::default()));
commands.spawn((Camera3d::default(), AtmosphereCamera::default()));
}
56 changes: 24 additions & 32 deletions examples/cycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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() {
Expand All @@ -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)
));
Expand Down
2 changes: 1 addition & 1 deletion examples/detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 1 addition & 5 deletions examples/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ fn main() {
}

fn setup(mut commands: Commands) {
commands.spawn((
Camera3dBundle::default(),
AtmosphereCamera::default(),
Spectator,
));
commands.spawn((Camera3d::default(), AtmosphereCamera::default(), Spectator));
}

fn change_gradient(mut commands: Commands, keys: Res<ButtonInput<KeyCode>>) {
Expand Down
6 changes: 1 addition & 5 deletions examples/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ fn main() {
}

fn setup(mut commands: Commands) {
commands.spawn((
Camera3dBundle::default(),
AtmosphereCamera::default(),
Spectator,
));
commands.spawn((Camera3d::default(), AtmosphereCamera::default(), Spectator));
}

fn change_model(mut commands: Commands, keys: Res<ButtonInput<KeyCode>>) {
Expand Down
6 changes: 1 addition & 5 deletions examples/nishita.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ fn main() {
}

fn setup(mut commands: Commands) {
commands.spawn((
Camera3dBundle::default(),
AtmosphereCamera::default(),
Spectator,
));
commands.spawn((Camera3d::default(), AtmosphereCamera::default(), Spectator));
}

fn change_nishita(mut commands: Commands, keys: Res<ButtonInput<KeyCode>>) {
Expand Down
10 changes: 1 addition & 9 deletions examples/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ fn main() {
}

fn setup(mut commands: Commands) {
commands.spawn((
Camera3dBundle::default(),
AtmosphereCamera::default(),
Spectator,
));
commands.spawn((Camera3d::default(), AtmosphereCamera::default(), Spectator));
}

// Change the resolution when the user presses a number key
Expand All @@ -30,8 +26,6 @@ fn change_resolution(
keys: Res<ButtonInput<KeyCode>>,
) {
if keys.just_pressed(KeyCode::Space) {
#[cfg(feature = "bevy/trace")]
// enabling "bevy/trace" (via "bevy/trace_chrome" or "bevy/trace_tracy") allows you to debug bevy_atmosphere
let _change_dithering_executed_span =
info_span!("executed", name = "settings::change_dithering").entered();
if let Some(mut settings) = settings {
Expand Down Expand Up @@ -69,8 +63,6 @@ fn change_resolution(

// A separate `change` fn makes it easier to debug in tracy.
fn change(mut commands: Commands, settings: Option<ResMut<AtmosphereSettings>>, resolution: u32) {
#[cfg(feature = "bevy/trace")]
// enabling "bevy/trace" (via "bevy/trace_chrome" or "bevy/trace_tracy") allows you to debug bevy_atmosphere
let _change_resolution_executed_span =
info_span!("executed", name = "settings::change_resolution").entered();
if let Some(mut settings) = settings {
Expand Down
52 changes: 23 additions & 29 deletions examples/splitscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -36,34 +35,31 @@ fn setup(
mut settings: ResMut<SpectatorSettings>,
) {
// 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)),
Expand All @@ -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)),
},
Expand Down
4 changes: 2 additions & 2 deletions macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand All @@ -15,7 +15,7 @@ proc-macro = true

[dependencies]
proc-macro-crate = "3.1"
bevy_macro_utils = "0.14"
bevy_macro_utils = "0.15"

syn = "2.0"
proc-macro2 = "1.0"
Expand Down
1 change: 1 addition & 0 deletions macros/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ pub fn derive_atmospheric(ast: syn::DeriveInput) -> Result<TokenStream> {
shader: handle,
shader_defs: vec![],
entry_point: Cow::from("main"),
zero_initialize_workgroup_memory: true,
});

let id = TypeId::of::<Self>();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! }
//!
//! fn setup(mut commands: Commands) {
//! commands.spawn((Camera3dBundle::default(), AtmosphereCamera::default()));
//! commands.spawn((Camera3d::default(), AtmosphereCamera::default()));
//! }
//! ```
//!
Expand Down
Loading

0 comments on commit cf36a87

Please sign in to comment.