Merge branch 'main' into demo
This commit is contained in:
@@ -10,7 +10,7 @@ linked = ["openxr/linked", "openxr/static"]
|
||||
[dependencies]
|
||||
anyhow = "1.0.75"
|
||||
ash = "0.37.3"
|
||||
bevy = { git = "https://github.com/bevyengine/bevy.git" }
|
||||
bevy = "0.12"
|
||||
openxr = { version = "0.17.1", features = ["mint"] }
|
||||
mint = "0.5.9"
|
||||
wgpu = "0.17.1"
|
||||
@@ -18,7 +18,7 @@ wgpu-core = { version = "0.17.1", features = ["vulkan"] }
|
||||
wgpu-hal = "0.17.1"
|
||||
|
||||
[dev-dependencies]
|
||||
bevy = { git = "https://github.com/bevyengine/bevy.git" }
|
||||
bevy = "0.12"
|
||||
color-eyre = "0.6.2"
|
||||
bevy_rapier3d = { git = "https://github.com/alexichepura/bevy_rapier", version = "0.22.0", branch = "bevy-012"}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ target_sdk_version = 32
|
||||
|
||||
[dependencies]
|
||||
bevy_openxr = { path = "../..", default-features = false }
|
||||
bevy = { git = "https://github.com/bevyengine/bevy.git" }
|
||||
bevy = "0.12"
|
||||
openxr = { git = "https://github.com/Ralith/openxrs", features = ["mint"] }
|
||||
|
||||
[profile.release]
|
||||
|
||||
@@ -5,10 +5,25 @@ Get libopenxr_loader.so from the Oculus OpenXR Mobile SDK and add it to `example
|
||||
https://developer.oculus.com/downloads/package/oculus-openxr-mobile-sdk/
|
||||
`examples/android/runtime_libs/arm64-v8a/libopenxr_loader.so`
|
||||
|
||||
## Run
|
||||
Running on Meta Quest can be done with https://github.com/rust-mobile/cargo-apk.
|
||||
```sh
|
||||
cargo apk run --release
|
||||
```
|
||||
But cargo-apk is deprecated in favour of xbuild https://github.com/rust-mobile/xbuild.
|
||||
```sh
|
||||
# Install latest version of xbuild
|
||||
cargo install --git https://github.com/rust-mobile/xbuild
|
||||
```
|
||||
```sh
|
||||
# List devices and copy device string "adb:***"
|
||||
x devices
|
||||
|
||||
# Run on this device
|
||||
x run --release --device adb:***
|
||||
```
|
||||
There is [manifest.yaml](./manifest.yaml) example required by xbuild.
|
||||
Interface for this manifest can be found as AndroidConfig struct in https://github.com/rust-mobile/xbuild/blob/master/xbuild/src/config.rs
|
||||
|
||||
## Notes
|
||||
|
||||
|
||||
25
examples/android/manifest.yaml
Normal file
25
examples/android/manifest.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
android:
|
||||
runtime_libs:
|
||||
- "runtime_libs"
|
||||
manifest:
|
||||
package: "org.bevyengine.example_openxr_android"
|
||||
application:
|
||||
label: "Bevy Openxr Android"
|
||||
theme: "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
|
||||
meta_data:
|
||||
- name: "com.samsung.android.vr.application.mode"
|
||||
value: "vr_only"
|
||||
- name: "com.oculus.supportedDevices"
|
||||
value: "quest|quest2|quest3"
|
||||
activities:
|
||||
- config_changes: "density|keyboard|keyboardHidden|navigation|orientation|screenLayout|screenSize|uiMode"
|
||||
launch_mode: "singleTask"
|
||||
orientation: "landscape"
|
||||
intent_filters:
|
||||
- actions:
|
||||
- "android.intent.action.MAIN"
|
||||
categories:
|
||||
- "com.oculus.intent.category.VR"
|
||||
- "android.intent.category.LAUNCHER"
|
||||
sdk:
|
||||
target_sdk_version: 32
|
||||
@@ -259,7 +259,13 @@ pub fn xr_begin_frame(
|
||||
}
|
||||
{
|
||||
let _span = info_span!("xr_wait_frame").entered();
|
||||
*frame_state.lock().unwrap() = frame_waiter.lock().unwrap().wait().unwrap();
|
||||
*frame_state.lock().unwrap() = match frame_waiter.lock().unwrap().wait() {
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
warn!("error: {}", e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
}
|
||||
{
|
||||
let _span = info_span!("xr_begin_frame").entered();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::xr_input::{QuatConv, Vec3Conv};
|
||||
use crate::{LEFT_XR_TEXTURE_HANDLE, RIGHT_XR_TEXTURE_HANDLE};
|
||||
use bevy::core_pipeline::tonemapping::{DebandDither, Tonemapping};
|
||||
use bevy::math::Vec3A;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::camera::{CameraProjection, CameraRenderGraph, RenderTarget};
|
||||
use bevy::render::primitives::Frustum;
|
||||
@@ -216,6 +217,26 @@ impl CameraProjection for XRProjection {
|
||||
fn far(&self) -> f32 {
|
||||
self.far
|
||||
}
|
||||
|
||||
fn get_frustum_corners(&self, z_near: f32, z_far: f32) -> [Vec3A; 8] {
|
||||
let tan_angle_left = self.fov.angle_left.tan();
|
||||
let tan_angle_right = self.fov.angle_right.tan();
|
||||
|
||||
let tan_angle_bottom = self.fov.angle_down.tan();
|
||||
let tan_angle_top = self.fov.angle_up.tan();
|
||||
|
||||
// NOTE: These vertices are in the specific order required by [`calculate_cascade`].
|
||||
[
|
||||
Vec3A::new(tan_angle_right, tan_angle_bottom, 1.0) * z_near, // bottom right
|
||||
Vec3A::new(tan_angle_right, tan_angle_top, 1.0) * z_near, // top right
|
||||
Vec3A::new(tan_angle_left, tan_angle_top, 1.0) * z_near, // top left
|
||||
Vec3A::new(tan_angle_left, tan_angle_bottom, 1.0) * z_near, // bottom left
|
||||
Vec3A::new(tan_angle_right, tan_angle_bottom, 1.0) * z_far, // bottom right
|
||||
Vec3A::new(tan_angle_right, tan_angle_top, 1.0) * z_far, // top right
|
||||
Vec3A::new(tan_angle_left, tan_angle_top, 1.0) * z_far, // top left
|
||||
Vec3A::new(tan_angle_left, tan_angle_bottom, 1.0) * z_far, // bottom left
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
pub fn xr_camera_head_sync(
|
||||
|
||||
Reference in New Issue
Block a user