Skip to content

Commit

Permalink
Merge pull request #163 from Schmarni-Dev/0.15rc
Browse files Browse the repository at this point in the history
update to bevy 0.15
  • Loading branch information
Schmarni-Dev authored Jan 1, 2025
2 parents 901b9bc + 336c40d commit 03a97f4
Show file tree
Hide file tree
Showing 39 changed files with 1,451 additions and 1,324 deletions.
1,534 changes: 878 additions & 656 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ resolver = "2"
members = ["crates/*", "crates/bevy_openxr/examples/android"]

[workspace.dependencies]
bevy = { version = "0.14.0", default-features = false, features = [
bevy = { version = "0.15", default-features = false, features = [
"bevy_render",
"bevy_core_pipeline",
"bevy_winit",
"bevy_pbr",
"x11",
] }
bevy_mod_xr.path = "crates/bevy_xr"
bevy_mod_openxr.path = "crates/bevy_openxr"
bevy_xr_utils.path = "crates/bevy_xr_utils"
openxr = "0.19.0"
thiserror = "2.0.3"
wgpu = "23"
wgpu-hal = "23"
24 changes: 11 additions & 13 deletions crates/bevy_openxr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ keywords = ["gamedev", "bevy", "Xr", "Vr", "OpenXR"]
[features]
default = ["vulkan", "d3d12", "passthrough"]
vulkan = ["dep:ash"]
d3d12 = ["wgpu/dx12", "wgpu-hal/dx12", "dep:winapi", "dep:d3d12"]
d3d12 = ["wgpu/dx12", "wgpu-hal/dx12", "dep:winapi"]
passthrough = []

[dev-dependencies]
bevy_xr_utils.path = "../bevy_xr_utils"
bevy_xr_utils.workspace = true
bevy = { workspace = true, default-features = true }

[target.'cfg(target_os = "android")'.dependencies]
Expand All @@ -27,22 +27,20 @@ bevy.workspace = true

# all other dependencies are placed under this since on wasm, this crate is completely empty
[target.'cfg(not(target_family = "wasm"))'.dependencies]
openxr = "0.18.0"
thiserror = "1.0.57"
wgpu = "0.20"
wgpu-hal = "0.21"
bevy_mod_xr = { path = "../bevy_xr", version = "0.1.0" }

ash = { version = "0.37.3", optional = true }
bevy_mod_xr.workspace = true
openxr.workspace = true
thiserror.workspace = true
wgpu.workspace = true
wgpu-hal.workspace = true
ash = { version = "0.38", optional = true }

[target.'cfg(target_family = "unix")'.dependencies]
openxr = { version = "0.18.0", features = ["mint"] }
wgpu = { version = "0.20", features = ["vulkan-portability"] }
openxr = { workspace = true, features = ["mint"] }
wgpu = { workspace = true, features = ["vulkan-portability"] }

[target.'cfg(target_family = "windows")'.dependencies]
openxr = { version = "0.18.0", features = ["mint", "static"] }
openxr = { workspace=true, features = ["mint", "static"] }
winapi = { version = "0.3.9", optional = true }
d3d12 = { version = "0.20", features = ["libloading"], optional = true }

[lints.clippy]
too_many_arguments = "allow"
Expand Down
57 changes: 33 additions & 24 deletions crates/bevy_openxr/examples/3d_scene.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
//! A simple 3D scene with light shining over a cube sitting on a plane.
use bevy::prelude::*;
use bevy_mod_openxr::add_xr_plugins;
use bevy::{prelude::*, render::pipelined_rendering::PipelinedRenderingPlugin};
use bevy_mod_openxr::{add_xr_plugins, init::OxrInitPlugin};
use openxr::EnvironmentBlendMode;

fn main() {
App::new()
.add_plugins(add_xr_plugins(DefaultPlugins))
.add_plugins(
add_xr_plugins(DefaultPlugins.build().disable::<PipelinedRenderingPlugin>()).set(
OxrInitPlugin {
blend_modes: Some(vec![
EnvironmentBlendMode::ALPHA_BLEND,
EnvironmentBlendMode::ADDITIVE,
]),
..Default::default()
},
),
)
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
.add_systems(Startup, setup)
.insert_resource(ClearColor(Color::NONE))
.run();
}

Expand All @@ -18,30 +30,27 @@ fn setup(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// circular base
commands.spawn(PbrBundle {
mesh: meshes.add(Circle::new(4.0)),
material: materials.add(Color::WHITE),
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Circle::new(4.0))),
MeshMaterial3d(materials.add(Color::WHITE)),
Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
));
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
Transform::from_xyz(0.0, 0.5, 0.0),
));
// light
commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
Transform::from_xyz(4.0, 8.0, 4.0),
));
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}
32 changes: 15 additions & 17 deletions crates/bevy_openxr/examples/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,22 @@ fn setup_scene(
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// circular base
commands.spawn(PbrBundle {
mesh: meshes.add(Circle::new(4.0)),
material: materials.add(Color::WHITE),
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Circle::new(4.0))),
MeshMaterial3d(materials.add(Color::WHITE)),
Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
));
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
Transform::from_xyz(0.0, 0.5, 0.0),
));

commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}

#[derive(Component)]
Expand Down Expand Up @@ -145,7 +143,7 @@ fn handle_flight_input(
let locomotion_vector = reference_quat.mul_vec3(input_vector);

root_position.translation +=
locomotion_vector * speed * time.delta_seconds();
locomotion_vector * speed * time.delta_secs();
}
None => return,
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_openxr/examples/android/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bevy_mod_openxr.path = "../.."
bevy_mod_openxr.workspace = true
bevy = { workspace = true, default-features = true }
bevy_xr_utils.path = "../../../bevy_xr_utils"
bevy_xr_utils.workspace = true

[build-dependencies]
reqwest = { version = "0.12", features = ["blocking"] }
Expand Down
33 changes: 20 additions & 13 deletions crates/bevy_openxr/examples/android/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ fn main() {
synchronous_pipeline_compilation: default(),
}))
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
.insert_resource(Msaa::Off)
.add_systems(Startup, setup)
.add_systems(Update, modify_msaa)
.insert_resource(AmbientLight {
color: Default::default(),
brightness: 500.0,
Expand All @@ -31,6 +31,15 @@ fn main() {
.run();
}

#[derive(Component)]
struct MsaaModified;

fn modify_msaa(cams: Query<Entity, (With<Camera>, Without<MsaaModified>)>, mut commands: Commands) {
for cam in &cams {
commands.entity(cam).insert(Msaa::Off).insert(MsaaModified);
}
}

/// set up a simple 3D scene
fn setup(
mut commands: Commands,
Expand All @@ -40,19 +49,17 @@ fn setup(
let mut white: StandardMaterial = Color::WHITE.into();
white.unlit = true;
// circular base
commands.spawn(PbrBundle {
mesh: meshes.add(Circle::new(4.0)),
material: materials.add(white),
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Circle::new(4.0))),
MeshMaterial3d(materials.add(white)),
Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
));
let mut cube_mat: StandardMaterial = Color::srgb_u8(124, 144, 255).into();
cube_mat.unlit = true;
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(cube_mat),
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(cube_mat)),
Transform::from_xyz(0.0, 0.5, 0.0),
));
}
78 changes: 33 additions & 45 deletions crates/bevy_openxr/examples/overlay.rs
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
//! A simple 3D scene with light shining over a cube sitting on a plane.
use bevy::prelude::*;
use bevy_mod_openxr::{add_xr_plugins, init::OxrInitPlugin, types::OxrExtensions};
use bevy_mod_xr::session::XrState;
// use openxr::EnvironmentBlendMode;
// use wgpu::TextureFormat;
use bevy_mod_openxr::{
add_xr_plugins, features::overlay::OxrOverlaySessionEvent, init::OxrInitPlugin,
types::OxrExtensions,
};
use openxr::EnvironmentBlendMode;

fn main() {
App::new()
.add_plugins(add_xr_plugins(DefaultPlugins).build().set(OxrInitPlugin {
exts: {
let mut exts = OxrExtensions::default();
exts.enable_hand_tracking();
exts.other.push("XR_EXTX_overlay\0".into());
exts.extx_overlay = true;
exts
},
// blend_modes: Some({
// let mut v = Vec::new();
// v.push(EnvironmentBlendMode::ALPHA_BLEND);
// v.push(EnvironmentBlendMode::ADDITIVE);
// v.push(EnvironmentBlendMode::OPAQUE);
// v
// }),
// formats: Some({
// let mut v = Vec::new();
// // v.push(TextureFormat::Rgba8Uint);
// v.push(TextureFormat::Rgba8Unorm);
// v.push(TextureFormat::Rgba8UnormSrgb);
// v
// }),
blend_modes: Some({
vec![
EnvironmentBlendMode::ALPHA_BLEND,
EnvironmentBlendMode::OPAQUE,
]
}),
..OxrInitPlugin::default()
}))
.insert_resource(ClearColor(Color::NONE))
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
.add_systems(Startup, setup)
.add_systems(Update, handle_input)
.add_systems(Update, print_main_session_changes)
.run();
}

fn print_main_session_changes(mut events: EventReader<OxrOverlaySessionEvent>) {
for event in events.read() {
let OxrOverlaySessionEvent::MainSessionVisibilityChanged { visible, flags: _ } = event;
info!("main session visible: {visible}");
}
}

fn handle_input(
keys: Res<ButtonInput<KeyCode>>,
mut end: EventWriter<bevy_mod_xr::session::XrEndSessionEvent>,
mut destroy: EventWriter<bevy_mod_xr::session::XrDestroySessionEvent>,
mut begin: EventWriter<bevy_mod_xr::session::XrBeginSessionEvent>,
mut create: EventWriter<bevy_mod_xr::session::XrCreateSessionEvent>,
mut request_exit: EventWriter<bevy_mod_xr::session::XrRequestExitEvent>,
state: Res<XrState>,
) {
if keys.just_pressed(KeyCode::KeyE) {
info!("sending end");
Expand All @@ -67,9 +67,6 @@ fn handle_input(
info!("sending request exit");
request_exit.send_default();
}
if keys.just_pressed(KeyCode::KeyI) {
info!("current state: {:?}", *state);
}
}

/// set up a simple 3D scene
Expand All @@ -78,31 +75,22 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// circular base
// commands.spawn(PbrBundle {
// mesh: meshes.add(Circle::new(4.0)),
// material: materials.add(Color::WHITE),
// transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
// ..default()
// });
// cube
commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 2.5, 0.0),
..default()
});
commands.spawn((
Mesh3d(meshes.add(Cuboid::new(1.0, 1.0, 1.0))),
MeshMaterial3d(materials.add(Color::srgb_u8(124, 144, 255))),
Transform::from_xyz(0.0, 2.5, 0.0),
));
// light
commands.spawn(PointLightBundle {
point_light: PointLight {
commands.spawn((
PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()
});
Transform::from_xyz(4.0, 8.0, 4.0),
));
commands.spawn((
Camera3d::default(),
Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
));
}
Loading

0 comments on commit 03a97f4

Please sign in to comment.