update to bevy 0.14

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2024-07-05 03:19:02 +02:00
parent 5e0c09eaee
commit 81779bd76e
21 changed files with 850 additions and 400 deletions

1126
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,15 @@
[package] [package]
name = "bevy_mod_xr_backends" name = "bevy_mod_xr_backends"
version = "0.1.0" version.workspace = true
edition.workspace = true
description.workspace = true
repository.workspace = true
license.workspace = true
[workspace.package]
version = "0.1.0-rc1"
edition = "2021" edition = "2021"
description = "Community crate for OpenXR in Bevy" description = "Community crate for XR in Bevy"
repository = "https://github.com/awtterpip/bevy_oxr" repository = "https://github.com/awtterpip/bevy_oxr"
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
@@ -15,4 +22,4 @@ bevy.workspace = true
members = ["crates/*", "crates/bevy_openxr/examples/android"] members = ["crates/*", "crates/bevy_openxr/examples/android"]
[workspace.dependencies] [workspace.dependencies]
bevy = "0.13.0" bevy = "0.14.0"

View File

@@ -1,7 +1,7 @@
[package] [package]
name = "bevy_mod_openxr" name = "bevy_mod_openxr"
version = "0.1.0" version.workspace = true
edition = "2021" edition.workspace = true
[features] [features]
default = ["vulkan", "d3d12", "passthrough"] default = ["vulkan", "d3d12", "passthrough"]
@@ -24,9 +24,9 @@ bevy.workspace = true
[target.'cfg(not(target_family = "wasm"))'.dependencies] [target.'cfg(not(target_family = "wasm"))'.dependencies]
openxr = "0.18.0" openxr = "0.18.0"
thiserror = "1.0.57" thiserror = "1.0.57"
wgpu = "0.19.3" wgpu = "0.20"
wgpu-hal = "0.19.3" wgpu-hal = "0.21"
bevy_mod_xr.path = "../bevy_xr" bevy_mod_xr={path = "../bevy_xr",version = "0.1.0-rc1"}
ash = { version = "0.37.3", optional = true } ash = { version = "0.37.3", optional = true }

View File

@@ -27,7 +27,7 @@ fn setup(
// cube // cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(124, 144, 255)), material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0), transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default() ..default()
}); });

View File

@@ -43,7 +43,7 @@ fn setup_scene(
// cube // cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(124, 144, 255)), material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0), transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default() ..default()
}); });

View File

@@ -1,7 +1,8 @@
[package] [package]
name = "bevy_openxr_android" name = "bevy_openxr_android"
version = "0.1.0" version.workspace = true
edition = "2021" edition.workspace = true
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -46,7 +46,7 @@ fn setup(
transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)), transform: Transform::from_rotation(Quat::from_rotation_x(-std::f32::consts::FRAC_PI_2)),
..default() ..default()
}); });
let mut cube_mat: StandardMaterial = Color::rgb_u8(124, 144, 255).into(); let mut cube_mat: StandardMaterial = Color::srgb_u8(124, 144, 255).into();
cube_mat.unlit = true; cube_mat.unlit = true;
// cube // cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {

View File

@@ -88,7 +88,7 @@ fn setup(
// cube // cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(124, 144, 255)), material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 2.5, 0.0), transform: Transform::from_xyz(0.0, 2.5, 0.0),
..default() ..default()
}); });

View File

@@ -60,7 +60,7 @@ fn setup(
// cube // cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(124, 144, 255)), material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0), transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default() ..default()
}); });
@@ -132,7 +132,7 @@ fn spawn_hands(
.spawn(( .spawn((
PbrBundle { PbrBundle {
mesh: meshes.add(Cuboid::new(0.1, 0.1, 0.05)), mesh: meshes.add(Cuboid::new(0.1, 0.1, 0.05)),
material: materials.add(Color::rgb_u8(124, 144, 255)), material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0), transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default() ..default()
}, },
@@ -144,7 +144,7 @@ fn spawn_hands(
.spawn(( .spawn((
PbrBundle { PbrBundle {
mesh: meshes.add(Cuboid::new(0.1, 0.1, 0.05)), mesh: meshes.add(Cuboid::new(0.1, 0.1, 0.05)),
material: materials.add(Color::rgb_u8(124, 144, 255)), material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0), transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default() ..default()
}, },

View File

@@ -64,7 +64,7 @@ fn setup(
// cube // cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(124, 144, 255)), material: materials.add(Color::srgb_u8(124, 144, 255)),
transform: Transform::from_xyz(0.0, 0.5, 0.0), transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default() ..default()
}); });

View File

@@ -50,35 +50,35 @@ fn setup(
// red cube // red cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(252, 44, 3)), material: materials.add(Color::srgb_u8(252, 44, 3)),
transform: Transform::from_xyz(4.0, 0.5, 0.0).with_scale(Vec3::splat(0.5)), transform: Transform::from_xyz(4.0, 0.5, 0.0).with_scale(Vec3::splat(0.5)),
..default() ..default()
}); });
// blue cube // blue cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(3, 28, 252)), material: materials.add(Color::srgb_u8(3, 28, 252)),
transform: Transform::from_xyz(-4.0, 0.5, 0.0).with_scale(Vec3::splat(0.5)), transform: Transform::from_xyz(-4.0, 0.5, 0.0).with_scale(Vec3::splat(0.5)),
..default() ..default()
}); });
// green cube // green cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(3, 252, 32)), material: materials.add(Color::srgb_u8(3, 252, 32)),
transform: Transform::from_xyz(0.0, 0.5, 4.0).with_scale(Vec3::splat(0.5)), transform: Transform::from_xyz(0.0, 0.5, 4.0).with_scale(Vec3::splat(0.5)),
..default() ..default()
}); });
// white cube // white cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(250, 250, 250)), material: materials.add(Color::srgb_u8(250, 250, 250)),
transform: Transform::from_xyz(0.0, 0.5, -4.0).with_scale(Vec3::splat(0.5)), transform: Transform::from_xyz(0.0, 0.5, -4.0).with_scale(Vec3::splat(0.5)),
..default() ..default()
}); });
// black cube // black cube
commands.spawn(PbrBundle { commands.spawn(PbrBundle {
mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)), mesh: meshes.add(Cuboid::new(1.0, 1.0, 1.0)),
material: materials.add(Color::rgb_u8(0, 0, 0)), material: materials.add(Color::srgb_u8(0, 0, 0)),
transform: Transform::from_xyz(0.0, 0.1, 0.0).with_scale(Vec3::splat(0.2)), transform: Transform::from_xyz(0.0, 0.1, 0.0).with_scale(Vec3::splat(0.2)),
..default() ..default()
}); });

View File

@@ -15,10 +15,10 @@ pub struct OxrPassthroughPlugin;
impl Plugin for OxrPassthroughPlugin { impl Plugin for OxrPassthroughPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
let resources = app let resources = app
.world .world()
.get_resource::<OxrInstance>() .get_resource::<OxrInstance>()
.and_then(|instance| { .and_then(|instance| {
app.world app.world()
.get_resource::<OxrSystemId>() .get_resource::<OxrSystemId>()
.map(|system_id| (instance, system_id)) .map(|system_id| (instance, system_id))
}); });

View File

@@ -1,3 +1,5 @@
use std::sync::Arc;
use bevy::prelude::*; use bevy::prelude::*;
use bevy::render::extract_resource::ExtractResourcePlugin; use bevy::render::extract_resource::ExtractResourcePlugin;
use bevy::render::renderer::RenderAdapter; use bevy::render::renderer::RenderAdapter;
@@ -5,6 +7,7 @@ use bevy::render::renderer::RenderAdapterInfo;
use bevy::render::renderer::RenderDevice; use bevy::render::renderer::RenderDevice;
use bevy::render::renderer::RenderInstance; use bevy::render::renderer::RenderInstance;
use bevy::render::renderer::RenderQueue; use bevy::render::renderer::RenderQueue;
use bevy::render::renderer::WgpuWrapper;
use bevy::render::settings::RenderCreation; use bevy::render::settings::RenderCreation;
use bevy::render::MainWorld; use bevy::render::MainWorld;
use bevy::render::RenderApp; use bevy::render::RenderApp;
@@ -90,10 +93,10 @@ impl Plugin for OxrInitPlugin {
RenderPlugin { RenderPlugin {
render_creation: RenderCreation::manual( render_creation: RenderCreation::manual(
device.into(), device.into(),
RenderQueue(queue.into()), RenderQueue(Arc::new(WgpuWrapper::new(queue))),
RenderAdapterInfo(adapter_info), RenderAdapterInfo(WgpuWrapper::new(adapter_info)),
RenderAdapter(adapter.into()), RenderAdapter(Arc::new(WgpuWrapper::new(adapter))),
RenderInstance(wgpu_instance.into()), RenderInstance(Arc::new(WgpuWrapper::new(wgpu_instance))),
), ),
synchronous_pipeline_compilation: self.synchronous_pipeline_compilation, synchronous_pipeline_compilation: self.synchronous_pipeline_compilation,
}, },
@@ -121,10 +124,10 @@ impl Plugin for OxrInitPlugin {
.insert_non_send_resource(session_create_info) .insert_non_send_resource(session_create_info)
.init_non_send_resource::<OxrSessionCreateNextChain>(); .init_non_send_resource::<OxrSessionCreateNextChain>();
app.world app.world_mut()
.spawn((TransformBundle::default(), XrTrackingRoot)); .spawn((TransformBundle::default(), XrTrackingRoot));
app.world app.world_mut()
.resource_mut::<Events<XrStateChanged>>() .resource_mut::<Events<XrStateChanged>>()
.send(XrStateChanged(XrState::Available)); .send(XrStateChanged(XrState::Available));

View File

@@ -277,7 +277,7 @@ pub fn update_views_render_world(
let openxr::Vector3f { x, y, z } = view.pose.position; let openxr::Vector3f { x, y, z } = view.pose.position;
let translation = Vec3::new(x, y, z); let translation = Vec3::new(x, y, z);
transform.translation = translation; transform.translation = translation;
extracted_view.transform = root.0.mul_transform(transform); extracted_view.world_from_view = root.0.mul_transform(transform);
} }
} }

View File

@@ -1,7 +1,7 @@
[package] [package]
name = "bevy_mod_webxr" name = "bevy_mod_webxr"
version = "0.1.0" version.workspace = true
edition = "2021" edition.workspace = true
# bevy can't be placed behind target or proc macros won't work properly # bevy can't be placed behind target or proc macros won't work properly
[dependencies] [dependencies]
@@ -13,4 +13,4 @@ thiserror = "1.0.57"
wgpu = "0.19.3" wgpu = "0.19.3"
wgpu-hal = "0.19.3" wgpu-hal = "0.19.3"
bevy_mod_xr.path = "../bevy_xr" bevy_mod_xr = { path = "../bevy_xr", version = "0.1.0-rc1" }

View File

@@ -1,7 +1,7 @@
[package] [package]
name = "bevy_mod_xr" name = "bevy_mod_xr"
version = "0.1.0" version.workspace = true
edition = "2021" edition.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@@ -16,7 +16,7 @@ impl<A: Action> Plugin for ActionPlugin<A> {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.init_resource::<ActionList>() app.init_resource::<ActionList>()
.init_resource::<ActionState<A>>(); .init_resource::<ActionState<A>>();
app.world.resource_mut::<ActionList>().0.push(A::info()); app.world_mut().resource_mut::<ActionList>().0.push(A::info());
} }
} }

View File

@@ -28,7 +28,7 @@ impl Plugin for XrCameraPlugin {
PostUpdate, PostUpdate,
update_frusta::<XrProjection> update_frusta::<XrProjection>
.after(TransformSystem::TransformPropagate) .after(TransformSystem::TransformPropagate)
.before(VisibilitySystems::UpdatePerspectiveFrusta), .before(VisibilitySystems::UpdateFrusta),
); );
app.add_plugins(( app.add_plugins((
ExtractComponentPlugin::<XrProjection>::default(), ExtractComponentPlugin::<XrProjection>::default(),
@@ -58,10 +58,6 @@ impl Default for XrProjection {
pub struct XrCamera(pub u32); pub struct XrCamera(pub u32);
impl CameraProjection for XrProjection { impl CameraProjection for XrProjection {
fn get_projection_matrix(&self) -> Mat4 {
self.projection_matrix
}
fn update(&mut self, _width: f32, _height: f32) {} fn update(&mut self, _width: f32, _height: f32) {}
fn far(&self) -> f32 { fn far(&self) -> f32 {
@@ -92,6 +88,10 @@ impl CameraProjection for XrProjection {
view_space_corners view_space_corners
} }
fn get_clip_from_view(&self) -> Mat4 {
self.projection_matrix
}
} }
#[derive(Bundle)] #[derive(Bundle)]

View File

@@ -128,7 +128,7 @@ impl Plugin for XrSessionPlugin {
.in_set(XrHandleEvents), .in_set(XrHandleEvents),
); );
app.world app.world_mut()
.resource_mut::<MainScheduleOrder>() .resource_mut::<MainScheduleOrder>()
.labels .labels
.insert(0, XrFirst.intern()); .insert(0, XrFirst.intern());
@@ -139,7 +139,7 @@ impl Plugin for XrSessionPlugin {
} }
fn finish(&self, app: &mut App) { fn finish(&self, app: &mut App) {
if app.get_sub_app(RenderApp).is_err() { if app.get_sub_app(RenderApp).is_none() {
return; return;
} }

View File

@@ -7,8 +7,8 @@ edition = "2021"
[dependencies] [dependencies]
bevy.workspace = true bevy.workspace = true
bevy_mod_xr.path = "../bevy_xr" bevy_mod_xr = { path = "../bevy_xr", version = "0.1.0-rc1" }
bevy_mod_openxr.path = "../bevy_openxr" bevy_mod_openxr = { path = "../bevy_openxr", version = "0.1.0-rc1" }
[target.'cfg(not(target_family = "wasm"))'.dependencies] [target.'cfg(not(target_family = "wasm"))'.dependencies]
openxr = "0.18.0" openxr = "0.18.0"

View File

@@ -1,3 +1,4 @@
use bevy::color::palettes::css;
use bevy::{prelude::*, transform::TransformSystem}; use bevy::{prelude::*, transform::TransformSystem};
use bevy_mod_xr::hands::{HandBone, HandBoneRadius}; use bevy_mod_xr::hands::{HandBone, HandBoneRadius};
pub struct HandGizmosPlugin; pub struct HandGizmosPlugin;
@@ -19,16 +20,16 @@ fn draw_hand_gizmos(
} }
} }
fn gizmo_color(bone: &HandBone) -> Color { fn gizmo_color(bone: &HandBone) -> Srgba {
match bone { match bone {
HandBone::Palm => Color::WHITE, HandBone::Palm => css::WHITE,
HandBone::Wrist => Color::GRAY, HandBone::Wrist => css::GRAY,
b if b.is_thumb() => Color::RED, b if b.is_thumb() => css::RED,
b if b.is_index() => Color::ORANGE, b if b.is_index() => css::ORANGE,
b if b.is_middle() => Color::YELLOW, b if b.is_middle() => css::YELLOW,
b if b.is_ring() => Color::GREEN, b if b.is_ring() => css::GREEN,
b if b.is_little() => Color::BLUE, b if b.is_little() => css::BLUE,
// should be impossible to hit // should be impossible to hit
_ => Color::rgb(1.0, 0.0, 1.0), _ => Srgba::rgb(1.0, 0.0, 1.0),
} }
} }