From df71c7931d54c9fa5e8b9e1e201c2c3b5f9171fc Mon Sep 17 00:00:00 2001 From: Schmarni Date: Tue, 20 Feb 2024 09:15:21 +0100 Subject: [PATCH] update to bevy 0.13. TODO: fix view weirdness and do a pass over most of xr_input to turn the modules into plugins --- Cargo.toml | 12 ++--- examples/android/Cargo.toml | 2 +- examples/android/src/lib.rs | 26 ++++++---- examples/demo/Cargo.toml | 5 +- examples/demo/src/lib.rs | 55 ++++++++------------ examples/demo/src/setup.rs | 17 +++---- examples/globe.rs | 16 +++--- examples/xr.rs | 25 +++++----- src/graphics/vulkan.rs | 13 +++-- src/lib.rs | 2 + src/xr_input/debug_gizmos.rs | 23 +++++---- src/xr_input/interactions.rs | 17 ++++--- src/xr_input/mod.rs | 2 +- src/xr_input/prototype_locomotion.rs | 30 ++++++----- src/xr_input/trackers.rs | 36 +++++++------ src/xr_input/xr_camera.rs | 75 +++++++++++++++------------- 16 files changed, 179 insertions(+), 177 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bb93ce7..847c1b6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,12 +17,12 @@ members = ["examples/android", "examples/demo"] [dependencies] # anyhow = "1.0.75" ash = "0.37.3" -bevy = "0.12" +bevy = "0.13" futures-lite = "2.0.1" mint = "0.5.9" -wgpu = "0.17.1" -wgpu-core = { version = "0.17.1", features = ["vulkan"] } -wgpu-hal = "0.17.1" +wgpu = "0.19" +wgpu-core = { version = "0.19", features = ["vulkan"] } +wgpu-hal = "0.19" eyre = "0.6.11" [target.'cfg(windows)'.dependencies] @@ -46,7 +46,7 @@ ndk-context = "0.1" jni = "0.20" [dev-dependencies] -bevy = "0.12" +bevy = "0.13" bevy_rapier3d = { git = "https://github.com/devil-ira/bevy_rapier", branch = "bevy-0.12" } color-eyre = "0.6.2" @@ -58,4 +58,4 @@ path = "examples/xr.rs" debug = true [patch.crates-io] -ndk = { git = "https://github.com/Schmarni-Dev/ndk.git", branch = "070" } +# ndk = { git = "https://github.com/Schmarni-Dev/ndk.git", branch = "070" } diff --git a/examples/android/Cargo.toml b/examples/android/Cargo.toml index 1c412bc..cafa8c2 100644 --- a/examples/android/Cargo.toml +++ b/examples/android/Cargo.toml @@ -13,7 +13,7 @@ crate-type = ["rlib", "cdylib"] [dependencies] bevy_oxr.path = "../.." -bevy = "0.12" +bevy = "0.13" openxr = { git = "https://github.com/Ralith/openxrs", rev = "0177d2d", features = ["mint"] } # [profile.release] diff --git a/examples/android/src/lib.rs b/examples/android/src/lib.rs index a52a93c..9b1c664 100644 --- a/examples/android/src/lib.rs +++ b/examples/android/src/lib.rs @@ -17,7 +17,7 @@ use bevy_oxr::DefaultXrPlugins; #[bevy_main] fn main() { let mut xr_extensions = XrExtensions::default(); - xr_extensions.enable_fb_passthrough(); + // xr_extensions.enable_fb_passthrough(); xr_extensions.enable_hand_tracking(); App::new() .add_plugins(DefaultXrPlugins { @@ -31,7 +31,7 @@ fn main() { .add_plugins(LogDiagnosticsPlugin::default()) .add_plugins(FrameTimeDiagnosticsPlugin) .add_plugins(HandInputDebugRenderer) - .add_plugins(bevy_oxr::passthrough::EnablePassthroughStartup) + // .add_plugins(bevy_oxr::passthrough::EnablePassthroughStartup) .add_systems(Startup, setup) .add_systems( Update, @@ -57,21 +57,21 @@ fn setup( ) { // plane commands.spawn(PbrBundle { - mesh: meshes.add(shape::Plane::from_size(5.0).into()), - material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()), + mesh: meshes.add(Plane3d::new(Vec3::Y)), + material: materials.add(StandardMaterial::from(Color::rgb(0.3, 0.5, 0.3))), ..default() }); // cube commands.spawn(PbrBundle { - mesh: meshes.add(Mesh::from(shape::Cube { size: 0.1 })), - material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()), + mesh: meshes.add(Cuboid::from_size(Vec3::splat(0.1)).mesh()), + material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.7, 0.6))), transform: Transform::from_xyz(0.0, 0.5, 0.0), ..default() }); // cube commands.spawn(PbrBundle { - mesh: meshes.add(Mesh::from(shape::Cube { size: 0.1 })), - material: materials.add(Color::rgb(0.8, 0.0, 0.0).into()), + mesh: meshes.add(Mesh::from(Cuboid::from_size(Vec3::splat(0.1)))), + material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.0, 0.0))), transform: Transform::from_xyz(0.0, 0.5, 1.0), ..default() }); @@ -106,7 +106,7 @@ fn spawn_controllers_example(mut commands: Commands) { // TODO: make this a vr button fn toggle_passthrough( - keys: Res>, + keys: Res>, passthrough_state: Res, mut resume: EventWriter, mut pause: EventWriter, @@ -114,8 +114,12 @@ fn toggle_passthrough( if keys.just_pressed(KeyCode::Space) { match *passthrough_state { XrPassthroughState::Unsupported => {} - XrPassthroughState::Running => pause.send_default(), - XrPassthroughState::Paused => resume.send_default(), + XrPassthroughState::Running => { + pause.send_default(); + } + XrPassthroughState::Paused => { + resume.send_default(); + } } } } diff --git a/examples/demo/Cargo.toml b/examples/demo/Cargo.toml index 14e39de..00df137 100644 --- a/examples/demo/Cargo.toml +++ b/examples/demo/Cargo.toml @@ -9,9 +9,10 @@ crate-type = ["rlib", "cdylib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy = "0.12" +bevy = "0.13" bevy_oxr.path = "../../" -bevy_rapier3d = { git = "https://github.com/devil-ira/bevy_rapier", branch = "bevy-0.12" } +# bevy_rapier3d = { git = "https://github.com/devil-ira/bevy_rapier", branch = "bevy-0.12" } +bevy_rapier3d = "0.25" color-eyre = "0.6.2" diff --git a/examples/demo/src/lib.rs b/examples/demo/src/lib.rs index 8f369f9..2874dc9 100644 --- a/examples/demo/src/lib.rs +++ b/examples/demo/src/lib.rs @@ -1,19 +1,13 @@ use std::{f32::consts::PI, ops::Mul, time::Duration}; use bevy::{ - diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, - ecs::schedule::ScheduleLabel, - input::{keyboard::KeyCode, Input}, - log::info, - prelude::{ + diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, ecs::schedule::ScheduleLabel, input::{keyboard::KeyCode, ButtonInput}, log::info, math::primitives::{Capsule3d, Cuboid}, prelude::{ bevy_main, default, shape, App, Assets, Color, Commands, Component, Entity, Event, EventReader, EventWriter, FixedUpdate, Gizmos, GlobalTransform, IntoSystemConfigs, IntoSystemSetConfigs, Mesh, PbrBundle, PostUpdate, Quat, Query, Res, ResMut, Resource, Schedule, SpatialBundle, StandardMaterial, Startup, Transform, Update, Vec3, Vec3Swizzles, With, Without, World, - }, - time::{Fixed, Time, Timer, TimerMode}, - transform::TransformSystem, + }, render::mesh::Meshable, time::{Fixed, Time, Timer, TimerMode}, transform::TransformSystem }; use bevy_oxr::{ graphics::{extensions::XrExtensions, XrAppInfo, XrPreferdBlendMode}, @@ -226,12 +220,8 @@ fn spawn_capsule( ) { commands.spawn(( PbrBundle { - mesh: meshes.add(Mesh::from(shape::Capsule { - radius: 0.033, - depth: 0.115, - ..default() - })), - material: materials.add(Color::rgb(0.8, 0.7, 0.6).into()), + mesh: meshes.add(Capsule3d::new(0.033, 0.115).mesh()), + material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.7, 0.6))), transform: Transform::from_xyz(0.0, 2.0, 0.0), ..default() }, @@ -376,7 +366,7 @@ fn update_physics_hands( &Hand, &mut Velocity, )>, - hand_query: Query<(&Transform, &HandBone, &Hand, Without)>, + hand_query: Query<(&Transform, &HandBone, &Hand), Without>, time: Res