Merge pull request #75 from TheButlah/thebutlah/clean-up-workspace

cleaned up workspace
This commit is contained in:
Schmarni
2024-02-23 18:32:10 +01:00
committed by GitHub
7 changed files with 56 additions and 97 deletions

View File

@@ -22,8 +22,7 @@ jobs:
run: sudo apt-get install -y libasound2-dev portaudio19-dev build-essential libpulse-dev libdbus-1-dev libudev-dev libopenxr-loader1 libopenxr-dev run: sudo apt-get install -y libasound2-dev portaudio19-dev build-essential libpulse-dev libdbus-1-dev libudev-dev libopenxr-loader1 libopenxr-dev
- name: "Checks" - name: "Checks"
run: | run: |
cargo update cargo fmt --check --all
#cargo fmt --check
#cargo clippy --no-deps --tests -- -D warnings #cargo clippy --no-deps --tests -- -D warnings
#cargo rustdoc -- -D warnings #cargo rustdoc -- -D warnings
- name: "Build" - name: "Build"

View File

@@ -1,11 +1,28 @@
[workspace]
resolver = "2"
members = [
"examples/android",
"examples/demo",
]
[workspace.package]
edition = "2021"
license = "MIT OR Apache-2.0"
repository = "https://github.com/awtterpip/bevy_oxr"
[workspace.dependencies]
eyre = "0.6.2"
bevy = "0.13"
openxr = { git = "https://github.com/Ralith/openxrs", rev = "0177d2d" }
color-eyre = "0.6.2"
[package] [package]
name = "bevy_oxr" name = "bevy_oxr"
version = "0.1.0" version = "0.1.0"
edition = "2021"
description = "Community crate for OpenXR in Bevy" description = "Community crate for OpenXR in Bevy"
repository = "https://github.com/awtterpip/bevy_oxr" edition.workspace = true
license = "MIT/Apache-2.0" license.workspace = true
repository.workspace = true
[features] [features]
default = ["vulkan", "d3d12"] default = ["vulkan", "d3d12"]
@@ -13,47 +30,33 @@ force-link = ["openxr/linked"]
vulkan = ["wgpu-core/vulkan"] vulkan = ["wgpu-core/vulkan"]
d3d12 = ["wgpu-core/dx12", "dep:winapi", "dep:d3d12"] d3d12 = ["wgpu-core/dx12", "dep:winapi", "dep:d3d12"]
[workspace]
members = ["examples/android", "examples/demo"]
[dependencies] [dependencies]
# anyhow = "1.0.75"
ash = "0.37.3" ash = "0.37.3"
bevy = "0.13" bevy.workspace = true
eyre.workspace = true
futures-lite = "2.0.1" futures-lite = "2.0.1"
mint = "0.5.9" mint = "0.5.9"
wgpu = "0.19" wgpu = "0.19"
wgpu-core = { version = "0.19" } wgpu-core = { version = "0.19" }
wgpu-hal = "0.19" wgpu-hal = "0.19"
eyre = "0.6.11"
[target.'cfg(windows)'.dependencies] [target.'cfg(windows)'.dependencies]
openxr = { git = "https://github.com/Ralith/openxrs", rev = "0177d2d", features = [ openxr = { workspace = true, features = [ "linked", "static", "mint" ] }
"linked",
"static",
"mint",
] }
winapi = { version = "0.3.9", optional = true } winapi = { version = "0.3.9", optional = true }
d3d12 = { version = "0.19", features = ["libloading"], optional = true } d3d12 = { version = "0.19", features = ["libloading"], optional = true }
[target.'cfg(all(target_family = "unix", not(target_arch = "wasm32")) )'.dependencies] [target.'cfg(all(target_family = "unix", not(target_arch = "wasm32")) )'.dependencies]
openxr = { git = "https://github.com/Ralith/openxrs", rev = "0177d2d", features = [ openxr = { workspace = true, features = [ "mint" ] }
"mint",
] }
[target.'cfg(all(not(target_family = "unix"), not(target_arch = "wasm32")))'.dependencies] [target.'cfg(all(not(target_family = "unix"), not(target_arch = "wasm32")))'.dependencies]
openxr = { git = "https://github.com/Ralith/openxrs", rev = "0177d2d", features = [ openxr = { workspace = true, features = [ "mint", "static" ] }
"mint",
"static",
] }
[target.'cfg(target_os = "android")'.dependencies] [target.'cfg(target_os = "android")'.dependencies]
ndk-context = "0.1" ndk-context = "0.1"
jni = "0.20" jni = "0.20"
[dev-dependencies] [dev-dependencies]
bevy = "0.13" color-eyre.workspace = true
bevy_rapier3d = { git = "https://github.com/devil-ira/bevy_rapier", branch = "bevy-0.12" }
color-eyre = "0.6.2"
[[example]] [[example]]
name = "xr" name = "xr"
@@ -61,6 +64,3 @@ path = "examples/xr.rs"
[profile.release] [profile.release]
debug = true debug = true
[patch.crates-io]
# ndk = { git = "https://github.com/Schmarni-Dev/ndk.git", branch = "070" }

View File

@@ -1,10 +1,10 @@
[package] [package]
name = "bevy_openxr_android" name = "bevy_openxr_android"
version = "0.1.0" version = "0.1.0"
edition = "2021"
description = "Example for building an Android OpenXR app with Bevy" description = "Example for building an Android OpenXR app with Bevy"
edition.workspace = true
license.workspace = true
publish = false publish = false
license = "MIT OR Apache-2.0"
[lib] [lib]
name = "bevy_openxr_android" name = "bevy_openxr_android"
@@ -12,9 +12,9 @@ crate-type = ["rlib", "cdylib"]
[dependencies] [dependencies]
bevy_oxr.path = "../.."
bevy = "0.13" bevy = "0.13"
openxr = { git = "https://github.com/Ralith/openxrs", rev = "0177d2d", features = ["mint"] } bevy_oxr.path = "../.."
openxr = { workspace = true, features = ["mint"] }
# [profile.release] # [profile.release]
# lto = "fat" # lto = "fat"

View File

@@ -1,31 +1,15 @@
[package] [package]
name = "demo" name = "demo"
version = "0.1.0" version = "0.1.0"
edition = "2021" description = "Demo using bevy_oxr"
edition.workspace = true
publish = false
[lib] [lib]
crate-type = ["rlib", "cdylib"] crate-type = ["rlib", "cdylib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
bevy = "0.13" bevy.workspace = true
bevy_oxr.path = "../../" bevy_oxr.path = "../../"
# bevy_rapier3d = { git = "https://github.com/devil-ira/bevy_rapier", branch = "bevy-0.12" }
bevy_rapier3d = "0.25" bevy_rapier3d = "0.25"
color-eyre = "0.6.2" color-eyre.workspace = true
# [target.'cfg(not(target_os="android"))'.dependencies.bevy_oxr]
# path = "../../"
# # May need to be more specific. needs to be false at least on linux without an active runtime to run in flat
# default-features = true
[profile.release]
debug = true
[patch.crates-io]
ndk = { git = "https://github.com/Schmarni-Dev/ndk.git", branch = "070" }
ndk-sys = { package = "ndk-sys", git = "https://github.com/Schmarni-Dev/ndk.git", branch = "070" }
ndk-context = { package = "ndk-context", git = "https://github.com/Schmarni-Dev/ndk.git", branch = "070" }
ndk-glue = { package = "ndk-glue", git = "https://github.com/Schmarni-Dev/ndk.git", branch = "070" }

View File

@@ -1,27 +1,27 @@
use std::{f32::consts::PI, ops::Mul, time::Duration}; mod setup;
use std::time::Duration;
use bevy::{ use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin}, diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
ecs::schedule::ScheduleLabel, ecs::schedule::ScheduleLabel,
input::{keyboard::KeyCode, ButtonInput},
log::info, log::info,
math::primitives::{Capsule3d, Cuboid}, math::primitives::{Capsule3d, Cuboid},
prelude::{ prelude::{
bevy_main, default, shape, App, Assets, Color, Commands, Component, Entity, Event, bevy_main, default, App, Assets, Color, Commands, Component, Entity, Event, EventReader,
EventReader, EventWriter, FixedUpdate, Gizmos, GlobalTransform, IntoSystemConfigs, EventWriter, FixedUpdate, GlobalTransform, IntoSystemConfigs, IntoSystemSetConfigs, Mesh,
IntoSystemSetConfigs, Mesh, PbrBundle, PostUpdate, Quat, Query, Res, ResMut, Resource, PbrBundle, PostUpdate, Query, Res, ResMut, Resource, Schedule, SpatialBundle,
Schedule, SpatialBundle, StandardMaterial, Startup, Transform, Update, Vec3, Vec3Swizzles, StandardMaterial, Startup, Transform, Update, Vec3, With, Without, World,
With, Without, World,
}, },
render::mesh::Meshable, render::mesh::Meshable,
time::{Fixed, Time, Timer, TimerMode}, time::{Fixed, Time, Timer, TimerMode},
transform::TransformSystem, transform::TransformSystem,
}; };
use bevy_oxr::{ use bevy_oxr::{
graphics::{extensions::XrExtensions, XrAppInfo, XrPreferdBlendMode}, graphics::{extensions::XrExtensions, XrAppInfo},
input::XrInput, input::XrInput,
resources::{XrFrameState, XrInstance, XrSession}, resources::{XrFrameState, XrSession},
xr_init::{xr_only, XrStatus}, xr_init::xr_only,
xr_input::{ xr_input::{
actions::XrActionSets, actions::XrActionSets,
debug_gizmos::OpenXrDebugRenderer, debug_gizmos::OpenXrDebugRenderer,
@@ -34,29 +34,12 @@ use bevy_oxr::{
}, },
oculus_touch::OculusController, oculus_touch::OculusController,
prototype_locomotion::{proto_locomotion, PrototypeLocomotionConfig}, prototype_locomotion::{proto_locomotion, PrototypeLocomotionConfig},
trackers::{ trackers::{OpenXRController, OpenXRLeftController, OpenXRRightController, OpenXRTracker},
OpenXRController, OpenXRLeftController, OpenXRRightController, OpenXRTracker,
OpenXRTrackingRoot,
},
Hand, Hand,
}, },
DefaultXrPlugins, DefaultXrPlugins,
}; };
// fn input_stuff(
// keys: Res<Input<KeyCode>>,
// status: Res<XrEnableStatus>,
// mut request: EventWriter<XrEnableRequest>,
// ) {
// if keys.just_pressed(KeyCode::Space) {
// match status.into_inner() {
// XrEnableStatus::Enabled => request.send(XrEnableRequest::TryDisable),
// XrEnableStatus::Disabled => request.send(XrEnableRequest::TryEnable),
// }
// }
// }
mod setup;
use crate::setup::setup_scene; use crate::setup::setup_scene;
use bevy_rapier3d::prelude::*; use bevy_rapier3d::prelude::*;
@@ -376,7 +359,6 @@ fn update_physics_hands(
)>, )>,
hand_query: Query<(&Transform, &HandBone, &Hand), Without<PhysicsHandBone>>, hand_query: Query<(&Transform, &HandBone, &Hand), Without<PhysicsHandBone>>,
time: Res<Time>, time: Res<Time>,
mut gizmos: Gizmos,
) { ) {
let matching = MatchingType::VelocityMatching; let matching = MatchingType::VelocityMatching;
//sanity check do we even have hands? //sanity check do we even have hands?
@@ -532,13 +514,6 @@ fn get_start_and_end_entities(
}; };
} }
fn get_hand_res(res: &Res<'_, HandsResource>, hand: Hand) -> HandResource {
match hand {
Hand::Left => res.left.clone(),
Hand::Right => res.right.clone(),
}
}
#[derive(Event, Default)] #[derive(Event, Default)]
pub struct SpawnCubeRequest; pub struct SpawnCubeRequest;
@@ -549,7 +524,6 @@ fn request_cube_spawn(
oculus_controller: Res<OculusController>, oculus_controller: Res<OculusController>,
frame_state: Res<XrFrameState>, frame_state: Res<XrFrameState>,
xr_input: Res<XrInput>, xr_input: Res<XrInput>,
instance: Res<XrInstance>,
session: Res<XrSession>, session: Res<XrSession>,
mut writer: EventWriter<SpawnCubeRequest>, mut writer: EventWriter<SpawnCubeRequest>,
time: Res<Time>, time: Res<Time>,
@@ -580,7 +554,7 @@ fn cube_spawner(
mut materials: ResMut<Assets<StandardMaterial>>, mut materials: ResMut<Assets<StandardMaterial>>,
mut events: EventReader<SpawnCubeRequest>, mut events: EventReader<SpawnCubeRequest>,
) { ) {
for request in events.read() { for _request in events.read() {
// cube // cube
commands.spawn(( commands.spawn((
PbrBundle { PbrBundle {
@@ -607,7 +581,7 @@ fn prototype_interaction_input(
xr_input: Res<XrInput>, xr_input: Res<XrInput>,
session: Res<XrSession>, session: Res<XrSession>,
mut right_interactor_query: Query< mut right_interactor_query: Query<
(&mut XRInteractorState), &mut XRInteractorState,
( (
With<XRDirectInteractor>, With<XRDirectInteractor>,
With<OpenXRRightController>, With<OpenXRRightController>,
@@ -615,7 +589,7 @@ fn prototype_interaction_input(
), ),
>, >,
mut left_interactor_query: Query< mut left_interactor_query: Query<
(&mut XRInteractorState), &mut XRInteractorState,
( (
With<XRDirectInteractor>, With<XRDirectInteractor>,
With<OpenXRLeftController>, With<OpenXRLeftController>,

1
rustfmt.toml Normal file
View File

@@ -0,0 +1 @@
# Use defaults

View File

@@ -182,7 +182,8 @@ pub enum Backend {
D3D12, D3D12,
} }
fn clean_resources_render(mut cmds: &mut World) {
fn clean_resources_render(cmds: &mut World) {
// let session = cmds.remove_resource::<XrSession>().unwrap(); // let session = cmds.remove_resource::<XrSession>().unwrap();
cmds.remove_resource::<XrSession>(); cmds.remove_resource::<XrSession>();
cmds.remove_resource::<XrResolution>(); cmds.remove_resource::<XrResolution>();
@@ -199,7 +200,7 @@ fn clean_resources_render(mut cmds: &mut World) {
// } // }
warn!("Cleanup Resources Render"); warn!("Cleanup Resources Render");
} }
fn clean_resources(mut cmds: &mut World) { fn clean_resources(cmds: &mut World) {
cmds.remove_resource::<XrSession>(); cmds.remove_resource::<XrSession>();
cmds.remove_resource::<XrResolution>(); cmds.remove_resource::<XrResolution>();
cmds.remove_resource::<XrFormat>(); cmds.remove_resource::<XrFormat>();