Skip to content

Commit

Permalink
Update to Bevy 0.15
Browse files Browse the repository at this point in the history
  • Loading branch information
ptsd committed Nov 28, 2024
1 parent a35a493 commit 46edd58
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 84 deletions.
12 changes: 8 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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" }
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
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
2 changes: 1 addition & 1 deletion examples/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {

fn setup(mut commands: Commands) {
commands.spawn((
Camera3dBundle::default(),
Camera3d::default(),
AtmosphereCamera::default(),
Spectator,
));
Expand Down
2 changes: 1 addition & 1 deletion examples/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {

fn setup(mut commands: Commands) {
commands.spawn((
Camera3dBundle::default(),
Camera3d::default(),
AtmosphereCamera::default(),
Spectator,
));
Expand Down
2 changes: 1 addition & 1 deletion examples/nishita.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {

fn setup(mut commands: Commands) {
commands.spawn((
Camera3dBundle::default(),
Camera3d::default(),
AtmosphereCamera::default(),
Spectator,
));
Expand Down
2 changes: 1 addition & 1 deletion examples/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() {

fn setup(mut commands: Commands) {
commands.spawn((
Camera3dBundle::default(),
Camera3d::default(),
AtmosphereCamera::default(),
Spectator,
));
Expand Down
53 changes: 23 additions & 30 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,32 @@ 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 +74,15 @@ 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 {
order: 1,
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.0-rc.3"

syn = "2.0"
proc-macro2 = "1.0"
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
14 changes: 5 additions & 9 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 46edd58

Please sign in to comment.