Skip to content

Commit cf36a87

Browse files
ptsdShatur
andauthored
Update to Bevy 0.15 (#74)
Co-authored-by: Hennadii Chernyshchyk <genaloner@gmail.com>
1 parent 42e3170 commit cf36a87

17 files changed

+92
-126
lines changed

Cargo.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,18 @@ repository = "https://github.com/JonahPlusPlus/bevy_atmosphere"
1111
exclude = ["/assets/", "/examples/", "/.github/"]
1212

1313
[dependencies]
14-
bevy = { version = "0.14", default-features = false, features = [
14+
bevy = { version = "0.15", default-features = false, features = [
1515
"bevy_asset",
1616
"bevy_render",
1717
"bevy_pbr",
18+
"png", # Enable temporary due to 0.15 bug: https://github.com/bevyengine/bevy/issues/16563
1819
] }
19-
bevy_atmosphere_macros = { path = "macros", version = "0.6" }
20+
bevy_atmosphere_macros = { path = "macros", version = "0.7" }
2021
cfg-if = "1.0"
2122

2223
[dev-dependencies]
23-
bevy_spectator = "0.6"
24-
bevy = { version = "0.14", features = ["bevy_core_pipeline", "x11"] }
24+
bevy_spectator = "0.7"
25+
bevy = { version = "0.15", features = ["bevy_core_pipeline", "x11"] }
2526

2627
[features]
2728
default = ["basic", "all_models"]

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ For more information on the technicalities, you can check out the [technical doc
4040

4141
| bevy | bevy_atmosphere |
4242
|------|-----------------|
43+
| 0.15 | 0.11 |
4344
| 0.14 | 0.10 |
4445
| 0.13 | 0.9 |
4546
| 0.12 | 0.8 |

deny.toml

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
1-
[advisories]
2-
unmaintained = "deny"
3-
yanked = "deny"
4-
notice = "deny"
5-
61
[licenses]
7-
copyleft = "deny"
8-
allow-osi-fsf-free = "either"
2+
allow = [
3+
"Apache-2.0",
4+
"BSD-2-Clause",
5+
"BSD-3-Clause",
6+
"BSL-1.0",
7+
"CC0-1.0",
8+
"ISC",
9+
"MIT-0",
10+
"MIT",
11+
"Unicode-3.0",
12+
"Zlib",
13+
]
914

1015
[[licenses.clarify]]
1116
name = "stretch"

examples/basic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ fn main() {
1010
}
1111

1212
fn setup(mut commands: Commands) {
13-
commands.spawn((Camera3dBundle::default(), AtmosphereCamera::default()));
13+
commands.spawn((Camera3d::default(), AtmosphereCamera::default()));
1414
}

examples/cycle.rs

+24-32
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use bevy_spectator::{Spectator, SpectatorPlugin};
44

55
fn main() {
66
App::new()
7-
.insert_resource(Msaa::Sample4)
87
.insert_resource(AtmosphereModel::default()) // Default Atmosphere material, we can edit it to simulate another planet
98
.insert_resource(CycleTimer(Timer::new(
109
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(
3837
timer.0.tick(time.delta());
3938

4039
if timer.0.finished() {
41-
let t = time.elapsed_seconds_wrapped() / 2.0;
40+
let t = time.elapsed_secs_wrapped() / 2.0;
4241
atmosphere.sun_position = Vec3::new(0., t.sin(), t.cos());
4342

4443
if let Some((mut light_trans, mut directional)) = query.single_mut().into() {
@@ -56,49 +55,42 @@ fn setup_environment(
5655
) {
5756
// Our Sun
5857
commands.spawn((
59-
DirectionalLightBundle {
60-
..Default::default()
61-
},
58+
DirectionalLight::default(),
6259
Sun, // Marks the light as Sun
6360
));
6461

6562
// Simple transform shape just for reference
66-
commands.spawn(PbrBundle {
67-
mesh: meshes.add(Cuboid::default()),
68-
material: materials.add(StandardMaterial::from(Color::srgb(0.8, 0.8, 0.8))),
69-
..Default::default()
70-
});
63+
commands.spawn((
64+
Mesh3d(meshes.add(Cuboid::default())),
65+
MeshMaterial3d(materials.add(StandardMaterial::from(Color::srgb(0.8, 0.8, 0.8)))),
66+
));
7167

7268
// X axis
73-
commands.spawn(PbrBundle {
74-
mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)),
75-
material: materials.add(StandardMaterial::from(Color::srgb(0.8, 0.0, 0.0))),
76-
transform: Transform::from_xyz(1., 0., 0.),
77-
..Default::default()
78-
});
69+
commands.spawn((
70+
Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))),
71+
MeshMaterial3d(materials.add(StandardMaterial::from(Color::srgb(0.8, 0.0, 0.0)))),
72+
Transform::from_xyz(1., 0., 0.),
73+
));
7974

8075
// Y axis
81-
commands.spawn(PbrBundle {
82-
mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)),
83-
material: materials.add(StandardMaterial::from(Color::srgb(0.0, 0.8, 0.0))),
84-
transform: Transform::from_xyz(0., 1., 0.),
85-
..Default::default()
86-
});
76+
commands.spawn((
77+
Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))),
78+
MeshMaterial3d(materials.add(StandardMaterial::from(Color::srgb(0.0, 0.8, 0.0)))),
79+
Transform::from_xyz(0., 1., 0.),
80+
));
8781

8882
// Z axis
89-
commands.spawn(PbrBundle {
90-
mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)),
91-
material: materials.add(StandardMaterial::from(Color::srgb(0.0, 0.0, 0.8))),
92-
transform: Transform::from_xyz(0., 0., 1.),
93-
..Default::default()
94-
});
83+
commands.spawn((
84+
Mesh3d(meshes.add(Cuboid::new(0.5, 0.5, 0.5))),
85+
MeshMaterial3d(materials.add(StandardMaterial::from(Color::srgb(0.0, 0.0, 0.8)))),
86+
Transform::from_xyz(0., 0., 1.),
87+
));
9588

9689
// Spawn our camera
9790
commands.spawn((
98-
Camera3dBundle {
99-
transform: Transform::from_xyz(5., 0., 5.),
100-
..default()
101-
},
91+
Camera3d::default(),
92+
Transform::from_xyz(5., 0., 5.),
93+
Msaa::Sample4,
10294
AtmosphereCamera::default(), // Marks camera as having a skybox, by default it doesn't specify the render layers the skybox can be seen on
10395
Spectator, // Marks camera as spectator (specific to bevy_spectator)
10496
));

examples/detection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414
struct PrimaryCamera;
1515

1616
fn setup(mut commands: Commands) {
17-
commands.spawn((Camera3dBundle::default(), PrimaryCamera));
17+
commands.spawn((Camera3d::default(), PrimaryCamera));
1818
}
1919

2020
fn update(

examples/gradient.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ fn main() {
1414
}
1515

1616
fn setup(mut commands: Commands) {
17-
commands.spawn((
18-
Camera3dBundle::default(),
19-
AtmosphereCamera::default(),
20-
Spectator,
21-
));
17+
commands.spawn((Camera3d::default(), AtmosphereCamera::default(), Spectator));
2218
}
2319

2420
fn change_gradient(mut commands: Commands, keys: Res<ButtonInput<KeyCode>>) {

examples/models.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ fn main() {
1313
}
1414

1515
fn setup(mut commands: Commands) {
16-
commands.spawn((
17-
Camera3dBundle::default(),
18-
AtmosphereCamera::default(),
19-
Spectator,
20-
));
16+
commands.spawn((Camera3d::default(), AtmosphereCamera::default(), Spectator));
2117
}
2218

2319
fn change_model(mut commands: Commands, keys: Res<ButtonInput<KeyCode>>) {

examples/nishita.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ fn main() {
1212
}
1313

1414
fn setup(mut commands: Commands) {
15-
commands.spawn((
16-
Camera3dBundle::default(),
17-
AtmosphereCamera::default(),
18-
Spectator,
19-
));
15+
commands.spawn((Camera3d::default(), AtmosphereCamera::default(), Spectator));
2016
}
2117

2218
fn change_nishita(mut commands: Commands, keys: Res<ButtonInput<KeyCode>>) {

examples/settings.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@ fn main() {
1616
}
1717

1818
fn setup(mut commands: Commands) {
19-
commands.spawn((
20-
Camera3dBundle::default(),
21-
AtmosphereCamera::default(),
22-
Spectator,
23-
));
19+
commands.spawn((Camera3d::default(), AtmosphereCamera::default(), Spectator));
2420
}
2521

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

7064
// A separate `change` fn makes it easier to debug in tracy.
7165
fn change(mut commands: Commands, settings: Option<ResMut<AtmosphereSettings>>, resolution: u32) {
72-
#[cfg(feature = "bevy/trace")]
73-
// enabling "bevy/trace" (via "bevy/trace_chrome" or "bevy/trace_tracy") allows you to debug bevy_atmosphere
7466
let _change_resolution_executed_span =
7567
info_span!("executed", name = "settings::change_resolution").entered();
7668
if let Some(mut settings) = settings {

examples/splitscreen.rs

+23-29
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use bevy_spectator::{Spectator, SpectatorPlugin, SpectatorSettings};
1212
fn main() {
1313
println!("Demonstrates using `AtmosphereCamera.render_layers` to have multiple skyboxes in the scene at once\n\t- E: Switch camera");
1414
App::new()
15-
.insert_resource(Msaa::Sample4)
1615
.insert_resource(AtmosphereModel::new(Nishita {
1716
rayleigh_coefficient: Vec3::new(22.4e-6, 5.5e-6, 13.0e-6), // Change rayleigh coefficient to change color
1817
..default()
@@ -36,34 +35,31 @@ fn setup(
3635
mut settings: ResMut<SpectatorSettings>,
3736
) {
3837
// Plane
39-
commands.spawn(PbrBundle {
40-
mesh: meshes.add(Plane3d::default().mesh().size(100.0, 100.0)),
41-
material: materials.add(Color::srgb(0.3, 0.5, 0.3)),
42-
..default()
43-
});
38+
commands.spawn((
39+
Mesh3d(meshes.add(Plane3d::default().mesh().size(100.0, 100.0))),
40+
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.5, 0.3))),
41+
));
4442

4543
// Light
46-
commands.spawn(DirectionalLightBundle {
47-
transform: Transform::from_rotation(Quat::from_euler(
44+
commands.spawn((
45+
DirectionalLight {
46+
shadows_enabled: true,
47+
..default()
48+
},
49+
Transform::from_rotation(Quat::from_euler(
4850
EulerRot::ZYX,
4951
0.0,
5052
1.0,
5153
-std::f32::consts::FRAC_PI_4,
5254
)),
53-
directional_light: DirectionalLight {
54-
shadows_enabled: true,
55-
..default()
56-
},
57-
..default()
58-
});
55+
));
5956

6057
// Spawn left screen camera and make it the default spectator
6158
let left = commands
6259
.spawn((
63-
Camera3dBundle {
64-
transform: Transform::from_xyz(0.0, 25.0, -100.0).looking_at(Vec3::ZERO, Vec3::Y),
65-
..default()
66-
},
60+
Camera3d::default(),
61+
Transform::from_xyz(0.0, 25.0, -100.0).looking_at(Vec3::ZERO, Vec3::Y),
62+
Msaa::Sample4,
6763
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)
6864
AtmosphereCamera {
6965
render_layers: Some(RenderLayers::layer(1)),
@@ -77,19 +73,17 @@ fn setup(
7773

7874
// Spawn right screen camera
7975
commands.spawn((
80-
Camera3dBundle {
81-
transform: Transform::from_xyz(100.0, 50.0, 150.0).looking_at(Vec3::ZERO, Vec3::Y),
82-
camera: Camera {
83-
// Renders the right camera after the left camera, which has a default priority of 0
84-
order: 1,
85-
// Don't clear on the second camera because the first camera already cleared the window
86-
clear_color: ClearColorConfig::None,
87-
..default()
88-
},
89-
camera_3d: Camera3d::default(),
76+
Camera {
77+
// Renders the right camera after the left camera, which has a default priority of 0
78+
order: 1,
79+
// Don't clear on the second camera because the first camera already cleared the window
80+
clear_color: ClearColorConfig::None,
9081
..default()
9182
},
92-
RenderLayers::from_layers(&[0, 2]),
83+
Camera3d::default(),
84+
Transform::from_xyz(100.0, 50.0, 150.0).looking_at(Vec3::ZERO, Vec3::Y),
85+
Msaa::Sample4,
86+
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)
9387
AtmosphereCamera {
9488
render_layers: Some(RenderLayers::layer(2)),
9589
},

macros/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy_atmosphere_macros"
33
description = "Proc macros for bevy_atmosphere"
4-
version = "0.6.0"
4+
version = "0.7.0"
55
edition = "2021"
66
authors = ["JonahPlusPlus <33059163+JonahPlusPlus@users.noreply.github.com>"]
77
license = "MIT OR Apache-2.0"
@@ -15,7 +15,7 @@ proc-macro = true
1515

1616
[dependencies]
1717
proc-macro-crate = "3.1"
18-
bevy_macro_utils = "0.14"
18+
bevy_macro_utils = "0.15"
1919

2020
syn = "2.0"
2121
proc-macro2 = "1.0"

macros/src/model.rs

+1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ pub fn derive_atmospheric(ast: syn::DeriveInput) -> Result<TokenStream> {
467467
shader: handle,
468468
shader_defs: vec![],
469469
entry_point: Cow::from("main"),
470+
zero_initialize_workgroup_memory: true,
470471
});
471472

472473
let id = TypeId::of::<Self>();

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//! }
1717
//!
1818
//! fn setup(mut commands: Commands) {
19-
//! commands.spawn((Camera3dBundle::default(), AtmosphereCamera::default()));
19+
//! commands.spawn((Camera3d::default(), AtmosphereCamera::default()));
2020
//! }
2121
//! ```
2222
//!

0 commit comments

Comments
 (0)