Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow XR Session starting and stopping at runtime #68

Merged
merged 26 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
aae751b
changed vulkan init code
Schmarni-Dev Jan 9, 2024
cbf9485
working
Schmarni-Dev Jan 13, 2024
144e786
ready to test
Schmarni-Dev Jan 14, 2024
87fe909
fix android warning
Schmarni-Dev Jan 15, 2024
6f6948e
borked
Schmarni-Dev Jan 23, 2024
a0ac82b
borked
Schmarni-Dev Jan 23, 2024
db5539c
removed weird file
Schmarni-Dev Jan 23, 2024
bc1985e
works on quest broken on wivrn
Schmarni-Dev Jan 23, 2024
a3c33cb
win + steamvr and quest working, wivrn still broken
Schmarni-Dev Jan 24, 2024
9d6d60c
implement simple pipelined rendering
Schmarni-Dev Jan 25, 2024
ac7c108
fixed pipelined rendering on quest 2
Schmarni-Dev Jan 26, 2024
1e4db18
commit
Schmarni-Dev Jan 27, 2024
5c81f13
fix late latching?
Schmarni-Dev Jan 29, 2024
9704607
stuff
Schmarni-Dev Feb 5, 2024
74c0813
wip
Schmarni-Dev Feb 5, 2024
ab8a95b
pull main, refactor passthrough
Schmarni-Dev Feb 5, 2024
3803968
clean up passthrough, change hand entity behavior and add cleanup ste…
Schmarni-Dev Feb 12, 2024
31d7b05
handtracking not working on quest 2 v62
Schmarni-Dev Feb 15, 2024
a95462b
pre bevy 0.13
Schmarni-Dev Feb 20, 2024
df71c79
update to bevy 0.13. TODO: fix view weirdness and do a pass over most…
Schmarni-Dev Feb 20, 2024
4779993
add prelude
Schmarni-Dev Feb 20, 2024
3f27c8d
core dumps on session end
Schmarni-Dev Feb 22, 2024
889ee3c
session restarting workscargo run --release --example xr! views fixed…
Schmarni-Dev Feb 22, 2024
bc6f263
pipelined rendering, quest handtracking fix for examples, choose exit…
Schmarni-Dev Feb 22, 2024
adb8b13
remove unnecessary log statements
Schmarni-Dev Feb 22, 2024
4f753b6
fmt
Schmarni-Dev Feb 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ force-link = ["openxr/linked"]
members = ["examples/android", "examples/demo"]

[dependencies]
anyhow = "1.0.75"
# 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]
openxr = { git = "https://github.com/Ralith/openxrs", rev = "0177d2d", features = [
Expand All @@ -45,9 +46,9 @@ ndk-context = "0.1"
jni = "0.20"

[dev-dependencies]
bevy = "0.12"
color-eyre = "0.6.2"
bevy = "0.13"
bevy_rapier3d = { git = "https://github.com/devil-ira/bevy_rapier", branch = "bevy-0.12" }
color-eyre = "0.6.2"

[[example]]
name = "xr"
Expand All @@ -57,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" }
10 changes: 5 additions & 5 deletions examples/android/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ 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]
lto = "fat"
codegen-units = 1
panic = "abort"
# [profile.release]
# lto = "fat"
# codegen-units = 1
# panic = "abort"

# This metadata is used by `cargo-apk` - `xbuild` uses the `manifest.yaml` instead.
[package.metadata.android]
Expand Down
2 changes: 2 additions & 0 deletions examples/android/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ android:
required: true
- name: "com.oculus.experimental.enabled"
required: true
uses_permission:
- name: "com.oculus.permission.HAND_TRACKING"
application:
label: "Bevy Openxr Android"
theme: "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
Expand Down
61 changes: 41 additions & 20 deletions examples/android/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use bevy::prelude::*;
use bevy::transform::components::Transform;
use bevy_oxr::graphics::extensions::XrExtensions;
use bevy_oxr::graphics::XrAppInfo;
use bevy_oxr::graphics::XrPreferdBlendMode::AlphaBlend;
use bevy_oxr::passthrough::{passthrough_layer_pause, passthrough_layer_resume};
use bevy_oxr::xr_init::XrRenderData;
use bevy_oxr::passthrough::{PausePassthrough, ResumePassthrough, XrPassthroughState};
use bevy_oxr::xr_init::xr_only;
use bevy_oxr::xr_input::debug_gizmos::OpenXrDebugRenderer;
use bevy_oxr::xr_input::hands::common::HandInputDebugRenderer;
use bevy_oxr::xr_input::hands::HandBone;
use bevy_oxr::xr_input::prototype_locomotion::{proto_locomotion, PrototypeLocomotionConfig};
use bevy_oxr::xr_input::trackers::{
OpenXRController, OpenXRLeftController, OpenXRRightController, OpenXRTracker,
Expand All @@ -16,7 +17,8 @@ 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 {
reqeusted_extensions: xr_extensions,
Expand All @@ -25,16 +27,28 @@ fn main() {
},
prefered_blend_mode: bevy_oxr::graphics::XrPreferdBlendMode::Opaque,
})
.add_plugins(OpenXrDebugRenderer)
// .add_plugins(OpenXrDebugRenderer)
.add_plugins(LogDiagnosticsPlugin::default())
.add_plugins(FrameTimeDiagnosticsPlugin)
.add_plugins(HandInputDebugRenderer)
// .add_plugins(bevy_oxr::passthrough::EnablePassthroughStartup)
.add_systems(Startup, setup)
.add_systems(Update, (proto_locomotion, toggle_passthrough))
.add_systems(
Update,
(proto_locomotion, toggle_passthrough).run_if(xr_only()),
)
.add_systems(Update, debug_hand_render.run_if(xr_only()))
.add_systems(Startup, spawn_controllers_example)
.insert_resource(PrototypeLocomotionConfig::default())
.run();
}

fn debug_hand_render(query: Query<&GlobalTransform, With<HandBone>>, mut gizmos: Gizmos) {
for transform in &query {
gizmos.sphere(transform.translation(), Quat::IDENTITY, 0.01, Color::RED);
}
}

/// set up a simple 3D scene
fn setup(
mut commands: Commands,
Expand All @@ -43,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()
});
Expand Down Expand Up @@ -90,15 +104,22 @@ fn spawn_controllers_example(mut commands: Commands) {
));
}

// Does this work? Not getting logs
fn toggle_passthrough(keys: Res<Input<KeyCode>>, mut xr_data: ResMut<XrRenderData>) {
// TODO: make this a vr button
fn toggle_passthrough(
keys: Res<ButtonInput<KeyCode>>,
passthrough_state: Res<XrPassthroughState>,
mut resume: EventWriter<ResumePassthrough>,
mut pause: EventWriter<PausePassthrough>,
) {
if keys.just_pressed(KeyCode::Space) {
if xr_data.xr_passthrough_active {
passthrough_layer_pause(xr_data);
bevy::log::info!("Passthrough paused");
} else {
passthrough_layer_resume(xr_data);
bevy::log::info!("Passthrough resumed");
match *passthrough_state {
XrPassthroughState::Unsupported => {}
XrPassthroughState::Running => {
pause.send_default();
}
XrPassthroughState::Paused => {
resume.send_default();
}
}
}
}
5 changes: 3 additions & 2 deletions examples/demo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand Down
16 changes: 10 additions & 6 deletions examples/demo/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,29 @@ android:
- "runtime_libs"
manifest:
package: "org.bevyengine.demo_openxr_android"
# Are features and permissions fliped?
uses_feature:
- name: "android.hardware.vr.headtracking"
required: true
- name: "oculus.software.handtracking"
required: false
# - name: "com.oculus.feature.PASSTHROUGH"
# required: true
required: true
- name: "com.oculus.feature.PASSTHROUGH"
required: true
- name: "com.oculus.experimental.enabled"
required: true
uses_permission:
- name: "com.oculus.permission.HAND_TRACKING"
application:
label: "Bevy Openxr Android"
theme: "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
meta_data:
- name: "com.oculus.intent.category.VR"
value: "vr_only"
- name: "com.samsung.android.vr.application.mode"
value: "vr_only"
- name: "com.oculus.supportedDevices"
value: "quest|quest2|quest3"
value: "quest|quest2|quest3|questpro"
activities:
- config_changes: "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"
- config_changes: "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode|screenLayout"
launch_mode: "singleTask"
orientation: "landscape"
intent_filters:
Expand All @@ -31,5 +34,6 @@ android:
categories:
- "com.oculus.intent.category.VR"
- "android.intent.category.LAUNCHER"
- "org.khronos.openxr.intent.category.IMMERSIVE_HMD"
sdk:
target_sdk_version: 32
Loading
Loading