update to bevy 0.15 rc
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -16,7 +16,7 @@ impl Plugin for OxrActionBindingPlugin {
|
||||
app.add_event::<OxrSuggestActionBinding>();
|
||||
app.add_systems(
|
||||
Update,
|
||||
run_action_binding_sugestion.run_if(on_event::<XrSessionCreatedEvent>()),
|
||||
run_action_binding_sugestion.run_if(on_event::<XrSessionCreatedEvent>),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ impl Plugin for OxrActionBindingPlugin {
|
||||
// Event to allow requesting binding suggestion for new actions
|
||||
pub(crate) fn run_action_binding_sugestion(world: &mut World) {
|
||||
world.run_schedule(OxrSendActionBindings);
|
||||
world.run_system_once(bind_actions);
|
||||
_ = world.run_system_once(bind_actions);
|
||||
}
|
||||
|
||||
fn bind_actions(instance: Res<OxrInstance>, mut actions: EventReader<OxrSuggestActionBinding>) {
|
||||
|
||||
@@ -8,7 +8,7 @@ impl Plugin for OxrActionAttachingPlugin {
|
||||
app.add_systems(
|
||||
PostUpdate,
|
||||
attach_sets
|
||||
.run_if(on_event::<XrSessionCreatedEvent>())
|
||||
.run_if(on_event::<XrSessionCreatedEvent>)
|
||||
.after(run_action_binding_sugestion),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,14 +90,14 @@ fn spawn_default_hands(mut cmds: Commands, root: Query<Entity, With<XrTrackingRo
|
||||
OxrSpaceLocationFlags(openxr::SpaceLocationFlags::default()),
|
||||
)
|
||||
});
|
||||
cmds.entity(root).push_children(&left_bones);
|
||||
cmds.entity(root).push_children(&right_bones);
|
||||
cmds.push(SpawnHandTracker {
|
||||
cmds.entity(root).add_children(&left_bones);
|
||||
cmds.entity(root).add_children(&right_bones);
|
||||
cmds.queue(SpawnHandTracker {
|
||||
joints: XrHandBoneEntities(left_bones),
|
||||
tracker_bundle: DefaultHandTracker,
|
||||
side: HandSide::Left,
|
||||
});
|
||||
cmds.push(SpawnHandTracker {
|
||||
cmds.queue(SpawnHandTracker {
|
||||
joints: XrHandBoneEntities(right_bones),
|
||||
tracker_bundle: DefaultHandTracker,
|
||||
side: HandSide::Right,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#[cfg(all(feature = "d3d12", windows))]
|
||||
mod d3d12;
|
||||
// #[cfg(all(feature = "d3d12", windows))]
|
||||
// mod d3d12;
|
||||
#[cfg(feature = "vulkan")]
|
||||
pub mod vulkan;
|
||||
|
||||
@@ -8,7 +8,10 @@ use std::any::TypeId;
|
||||
use bevy::math::UVec2;
|
||||
use openxr::{FrameStream, FrameWaiter, Session};
|
||||
|
||||
use crate::{session::OxrSessionCreateNextChain, types::{AppInfo, OxrExtensions, Result, WgpuGraphics}};
|
||||
use crate::{
|
||||
session::OxrSessionCreateNextChain,
|
||||
types::{AppInfo, OxrExtensions, Result, WgpuGraphics},
|
||||
};
|
||||
|
||||
/// This is an extension trait to the [`Graphics`](openxr::Graphics) trait and is how the graphics API should be interacted with.
|
||||
pub unsafe trait GraphicsExt: openxr::Graphics {
|
||||
@@ -37,7 +40,7 @@ pub unsafe trait GraphicsExt: openxr::Graphics {
|
||||
instance: &openxr::Instance,
|
||||
system_id: openxr::SystemId,
|
||||
) -> Result<(WgpuGraphics, Self::SessionCreateInfo)>;
|
||||
unsafe fn create_session(
|
||||
unsafe fn create_session(
|
||||
instance: &openxr::Instance,
|
||||
system_id: openxr::SystemId,
|
||||
info: &Self::SessionCreateInfo,
|
||||
@@ -74,8 +77,8 @@ impl GraphicsBackend {
|
||||
const ALL: &'static [Self] = &[
|
||||
#[cfg(feature = "vulkan")]
|
||||
Self::Vulkan(()),
|
||||
#[cfg(all(feature = "d3d12", windows))]
|
||||
Self::D3D12(()),
|
||||
// #[cfg(all(feature = "d3d12", windows))]
|
||||
// Self::D3D12(()),
|
||||
];
|
||||
|
||||
pub fn available_backends(exts: &OxrExtensions) -> Vec<Self> {
|
||||
@@ -103,8 +106,8 @@ impl GraphicsBackend {
|
||||
pub enum GraphicsWrap<T: GraphicsType> {
|
||||
#[cfg(feature = "vulkan")]
|
||||
Vulkan(T::Inner<openxr::Vulkan>),
|
||||
#[cfg(all(feature = "d3d12", windows))]
|
||||
D3D12(T::Inner<openxr::D3D12>),
|
||||
// #[cfg(all(feature = "d3d12", windows))]
|
||||
// D3D12(T::Inner<openxr::D3D12>),
|
||||
}
|
||||
|
||||
impl<T: GraphicsType> GraphicsWrap<T> {
|
||||
@@ -173,12 +176,12 @@ macro_rules! graphics_match {
|
||||
type Api = openxr::Vulkan;
|
||||
graphics_match!(@arm_impl Vulkan; $expr $(=> $($return)*)?)
|
||||
},
|
||||
#[cfg(all(feature = "d3d12", windows))]
|
||||
$crate::graphics::GraphicsWrap::D3D12($var) => {
|
||||
#[allow(unused)]
|
||||
type Api = openxr::D3D12;
|
||||
graphics_match!(@arm_impl D3D12; $expr $(=> $($return)*)?)
|
||||
},
|
||||
// #[cfg(all(feature = "d3d12", windows))]
|
||||
// $crate::graphics::GraphicsWrap::D3D12($var) => {
|
||||
// #[allow(unused)]
|
||||
// type Api = openxr::D3D12;
|
||||
// graphics_match!(@arm_impl D3D12; $expr $(=> $($return)*)?)
|
||||
// },
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ const VK_TARGET_VERSION_ASH: u32 = ash::vk::make_api_version(
|
||||
0,
|
||||
VK_TARGET_VERSION.major() as u32,
|
||||
VK_TARGET_VERSION.minor() as u32,
|
||||
VK_TARGET_VERSION.patch() as u32,
|
||||
VK_TARGET_VERSION.patch(),
|
||||
);
|
||||
|
||||
unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
@@ -63,7 +63,7 @@ unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: format,
|
||||
format,
|
||||
usage: wgpu_hal::TextureUses::COLOR_TARGET | wgpu_hal::TextureUses::COPY_DST,
|
||||
memory_flags: wgpu_hal::MemoryFlags::empty(),
|
||||
view_formats: vec![],
|
||||
@@ -84,7 +84,7 @@ unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
mip_level_count: 1,
|
||||
sample_count: 1,
|
||||
dimension: wgpu::TextureDimension::D2,
|
||||
format: format,
|
||||
format,
|
||||
usage: wgpu::TextureUsages::RENDER_ATTACHMENT | wgpu::TextureUsages::COPY_DST,
|
||||
view_formats: &[],
|
||||
},
|
||||
@@ -113,20 +113,20 @@ unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
let flags = wgpu::InstanceFlags::empty();
|
||||
let extensions =
|
||||
<Vulkan as Api>::Instance::desired_extensions(&vk_entry, VK_TARGET_VERSION_ASH, flags)?;
|
||||
let device_extensions = vec![
|
||||
ash::extensions::khr::Swapchain::name(),
|
||||
ash::extensions::khr::DrawIndirectCount::name(),
|
||||
#[cfg(target_os = "android")]
|
||||
ash::extensions::khr::TimelineSemaphore::name(),
|
||||
ash::vk::KhrImagelessFramebufferFn::name(),
|
||||
ash::vk::KhrImageFormatListFn::name(),
|
||||
let device_extensions = [
|
||||
ash::khr::swapchain::NAME,
|
||||
ash::khr::draw_indirect_count::NAME,
|
||||
// #[cfg(target_os = "android")]
|
||||
ash::khr::timeline_semaphore::NAME,
|
||||
ash::khr::imageless_framebuffer::NAME,
|
||||
ash::khr::image_format_list::NAME,
|
||||
];
|
||||
|
||||
let vk_instance = unsafe {
|
||||
let extensions_cchar: Vec<_> = extensions.iter().map(|s| s.as_ptr()).collect();
|
||||
|
||||
let app_name = CString::new(app_info.name.clone().into_owned())?;
|
||||
let vk_app_info = ash::vk::ApplicationInfo::builder()
|
||||
let vk_app_info = ash::vk::ApplicationInfo::default()
|
||||
.application_name(&app_name)
|
||||
.application_version(1)
|
||||
.engine_name(&app_name)
|
||||
@@ -136,8 +136,9 @@ unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
let vk_instance = instance
|
||||
.create_vulkan_instance(
|
||||
system_id,
|
||||
#[allow(clippy::missing_transmute_annotations)]
|
||||
std::mem::transmute(vk_entry.static_fn().get_instance_proc_addr),
|
||||
&ash::vk::InstanceCreateInfo::builder()
|
||||
&ash::vk::InstanceCreateInfo::default()
|
||||
.application_info(&vk_app_info)
|
||||
.enabled_extension_names(&extensions_cchar) as *const _
|
||||
as *const _,
|
||||
@@ -181,7 +182,7 @@ unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
extensions,
|
||||
flags,
|
||||
false,
|
||||
Some(Box::new(())),
|
||||
None,
|
||||
)?
|
||||
};
|
||||
|
||||
@@ -205,26 +206,26 @@ unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
.adapter
|
||||
.physical_device_features(&enabled_extensions, wgpu_features);
|
||||
let family_index = 0;
|
||||
let family_info = ash::vk::DeviceQueueCreateInfo::builder()
|
||||
let family_info = ash::vk::DeviceQueueCreateInfo::default()
|
||||
.queue_family_index(family_index)
|
||||
.queue_priorities(&[1.0])
|
||||
.build();
|
||||
.queue_priorities(&[1.0]);
|
||||
let family_infos = [family_info];
|
||||
let mut physical_device_multiview_features = ash::vk::PhysicalDeviceMultiviewFeatures {
|
||||
multiview: ash::vk::TRUE,
|
||||
..Default::default()
|
||||
};
|
||||
let info = enabled_phd_features
|
||||
.add_to_device_create_builder(
|
||||
ash::vk::DeviceCreateInfo::builder()
|
||||
.add_to_device_create(
|
||||
ash::vk::DeviceCreateInfo::default()
|
||||
.queue_create_infos(&family_infos)
|
||||
.push_next(&mut ash::vk::PhysicalDeviceMultiviewFeatures {
|
||||
multiview: ash::vk::TRUE,
|
||||
..Default::default()
|
||||
}),
|
||||
.push_next(&mut physical_device_multiview_features),
|
||||
)
|
||||
.enabled_extension_names(&extensions_cchar)
|
||||
.build();
|
||||
.enabled_extension_names(&extensions_cchar);
|
||||
let vk_device = unsafe {
|
||||
let vk_device = instance
|
||||
.create_vulkan_device(
|
||||
system_id,
|
||||
#[allow(clippy::missing_transmute_annotations)]
|
||||
std::mem::transmute(vk_entry.static_fn().get_instance_proc_addr),
|
||||
vk_physical_device.as_raw() as _,
|
||||
&info as *const _ as *const _,
|
||||
@@ -241,9 +242,10 @@ unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
let wgpu_open_device = unsafe {
|
||||
wgpu_exposed_adapter.adapter.device_from_raw(
|
||||
vk_device,
|
||||
true,
|
||||
None,
|
||||
&enabled_extensions,
|
||||
wgpu_features,
|
||||
&wgpu::MemoryHints::Performance,
|
||||
family_info.queue_family_index,
|
||||
0,
|
||||
)
|
||||
@@ -273,6 +275,7 @@ unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
max_push_constant_size: 4,
|
||||
..Default::default()
|
||||
},
|
||||
memory_hints: wgpu::MemoryHints::Performance,
|
||||
},
|
||||
None,
|
||||
)
|
||||
@@ -320,7 +323,7 @@ unsafe impl GraphicsExt for openxr::Vulkan {
|
||||
ty: sys::SessionCreateInfo::TYPE,
|
||||
next: &binding as *const _ as *const _,
|
||||
create_flags: Default::default(),
|
||||
system_id: system_id,
|
||||
system_id,
|
||||
};
|
||||
let mut out = sys::Session::NULL;
|
||||
cvt((instance.fp().create_session)(
|
||||
@@ -379,7 +382,7 @@ fn vulkan_to_wgpu(format: ash::vk::Format) -> Option<wgpu::TextureFormat> {
|
||||
F::R8G8B8A8_SINT => Tf::Rgba8Sint,
|
||||
F::A2B10G10R10_UINT_PACK32 => Tf::Rgb10a2Uint,
|
||||
F::A2B10G10R10_UNORM_PACK32 => Tf::Rgb10a2Unorm,
|
||||
F::B10G11R11_UFLOAT_PACK32 => Tf::Rg11b10Float,
|
||||
F::B10G11R11_UFLOAT_PACK32 => Tf::Rg11b10Ufloat,
|
||||
F::R32G32_UINT => Tf::Rg32Uint,
|
||||
F::R32G32_SINT => Tf::Rg32Sint,
|
||||
F::R32G32_SFLOAT => Tf::Rg32Float,
|
||||
@@ -630,7 +633,7 @@ fn wgpu_to_vulkan(format: wgpu::TextureFormat) -> Option<ash::vk::Format> {
|
||||
Tf::Rgba8Sint => F::R8G8B8A8_SINT,
|
||||
Tf::Rgb10a2Uint => F::A2B10G10R10_UINT_PACK32,
|
||||
Tf::Rgb10a2Unorm => F::A2B10G10R10_UNORM_PACK32,
|
||||
Tf::Rg11b10Float => F::B10G11R11_UFLOAT_PACK32,
|
||||
Tf::Rg11b10Ufloat => F::B10G11R11_UFLOAT_PACK32,
|
||||
Tf::Rg32Uint => F::R32G32_UINT,
|
||||
Tf::Rg32Sint => F::R32G32_SINT,
|
||||
Tf::Rg32Float => F::R32G32_SFLOAT,
|
||||
@@ -724,4 +727,3 @@ fn wgpu_to_vulkan(format: wgpu::TextureFormat) -> Option<ash::vk::Format> {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy_mod_xr::types::XrPose;
|
||||
use bevy::{math::Vec3A, prelude::*};
|
||||
|
||||
pub trait ToPosef {
|
||||
fn to_posef(&self) -> openxr::Posef;
|
||||
@@ -7,8 +6,8 @@ pub trait ToPosef {
|
||||
pub trait ToTransform {
|
||||
fn to_transform(&self) -> Transform;
|
||||
}
|
||||
pub trait ToXrPose {
|
||||
fn to_xr_pose(&self) -> XrPose;
|
||||
pub trait ToIsometry3d {
|
||||
fn to_xr_pose(&self) -> Isometry3d;
|
||||
}
|
||||
pub trait ToQuaternionf {
|
||||
fn to_quaternionf(&self) -> openxr::Quaternionf;
|
||||
@@ -42,15 +41,15 @@ impl ToTransform for openxr::Posef {
|
||||
.with_rotation(self.orientation.to_quat())
|
||||
}
|
||||
}
|
||||
impl ToXrPose for openxr::Posef {
|
||||
fn to_xr_pose(&self) -> XrPose {
|
||||
XrPose {
|
||||
translation: self.position.to_vec3(),
|
||||
impl ToIsometry3d for openxr::Posef {
|
||||
fn to_xr_pose(&self) -> Isometry3d {
|
||||
Isometry3d {
|
||||
translation: self.position.to_vec3().into(),
|
||||
rotation: self.orientation.to_quat(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ToPosef for XrPose {
|
||||
impl ToPosef for Isometry3d {
|
||||
fn to_posef(&self) -> openxr::Posef {
|
||||
openxr::Posef {
|
||||
orientation: self.rotation.to_quaternionf(),
|
||||
@@ -90,6 +89,15 @@ impl ToVector3f for Vec3 {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ToVector3f for Vec3A {
|
||||
fn to_vector3f(&self) -> openxr::Vector3f {
|
||||
openxr::Vector3f {
|
||||
x: self.x,
|
||||
y: self.y,
|
||||
z: self.z,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl ToVec3 for openxr::Vector3f {
|
||||
fn to_vec3(&self) -> Vec3 {
|
||||
Vec3 {
|
||||
|
||||
@@ -113,7 +113,7 @@ impl Plugin for OxrInitPlugin {
|
||||
(
|
||||
create_xr_session
|
||||
.run_if(state_equals(XrState::Available))
|
||||
.run_if(on_event::<XrCreateSessionEvent>()),
|
||||
.run_if(on_event::<XrCreateSessionEvent>),
|
||||
(
|
||||
destroy_xr_session,
|
||||
(|v: Res<XrDestroySessionRender>| {
|
||||
@@ -122,16 +122,16 @@ impl Plugin for OxrInitPlugin {
|
||||
}),
|
||||
)
|
||||
.run_if(state_matches!(XrState::Exiting { .. }))
|
||||
.run_if(on_event::<XrDestroySessionEvent>()),
|
||||
.run_if(on_event::<XrDestroySessionEvent>),
|
||||
begin_xr_session
|
||||
.run_if(state_equals(XrState::Ready))
|
||||
.run_if(on_event::<XrBeginSessionEvent>()),
|
||||
.run_if(on_event::<XrBeginSessionEvent>),
|
||||
end_xr_session
|
||||
.run_if(state_equals(XrState::Stopping))
|
||||
.run_if(on_event::<XrEndSessionEvent>()),
|
||||
.run_if(on_event::<XrEndSessionEvent>),
|
||||
request_exit_xr_session
|
||||
.run_if(session_created)
|
||||
.run_if(on_event::<XrRequestExitEvent>()),
|
||||
.run_if(on_event::<XrRequestExitEvent>),
|
||||
)
|
||||
.in_set(XrHandleEvents::SessionStateUpdateEvents),
|
||||
)
|
||||
@@ -146,9 +146,6 @@ impl Plugin for OxrInitPlugin {
|
||||
.insert_non_send_resource(session_create_info)
|
||||
.init_non_send_resource::<OxrSessionCreateNextChain>();
|
||||
|
||||
app.world_mut()
|
||||
.spawn((SpatialBundle::default(), XrTrackingRoot));
|
||||
|
||||
app.world_mut()
|
||||
.resource_mut::<Events<XrStateChanged>>()
|
||||
.send(XrStateChanged(XrState::Available));
|
||||
@@ -178,7 +175,7 @@ impl Plugin for OxrInitPlugin {
|
||||
})
|
||||
.run_if(
|
||||
resource_exists::<XrDestroySessionRender>
|
||||
.and_then(|v: Res<XrDestroySessionRender>| v.0.load(Ordering::Relaxed)),
|
||||
.and(|v: Res<XrDestroySessionRender>| v.0.load(Ordering::Relaxed)),
|
||||
)
|
||||
.chain(),
|
||||
);
|
||||
@@ -467,7 +464,7 @@ pub fn create_xr_session(world: &mut World) {
|
||||
let system_id = world.resource::<OxrSystemId>();
|
||||
match init_xr_session(
|
||||
device.wgpu_device(),
|
||||
&instance,
|
||||
instance,
|
||||
**system_id,
|
||||
&mut chain,
|
||||
create_info.clone(),
|
||||
@@ -475,8 +472,8 @@ pub fn create_xr_session(world: &mut World) {
|
||||
Ok((session, frame_waiter, frame_stream, swapchain, images, graphics_info)) => {
|
||||
world.insert_resource(session.clone());
|
||||
world.insert_resource(frame_waiter);
|
||||
world.insert_resource(images.clone());
|
||||
world.insert_resource(graphics_info.clone());
|
||||
world.insert_resource(images);
|
||||
world.insert_resource(graphics_info);
|
||||
world.insert_resource(OxrRenderResources {
|
||||
session,
|
||||
frame_stream,
|
||||
|
||||
@@ -37,14 +37,14 @@ impl LayerProvider for ProjectionLayer {
|
||||
Some(Box::new(
|
||||
CompositionLayerProjection::new()
|
||||
.layer_flags(CompositionLayerFlags::BLEND_TEXTURE_SOURCE_ALPHA)
|
||||
.space(&stage)
|
||||
.space(stage)
|
||||
.views(&[
|
||||
CompositionLayerProjectionView::new()
|
||||
.pose(openxr_views.0[0].pose)
|
||||
.fov(openxr_views.0[0].fov)
|
||||
.sub_image(
|
||||
SwapchainSubImage::new()
|
||||
.swapchain(&swapchain)
|
||||
.swapchain(swapchain)
|
||||
.image_array_index(0)
|
||||
.image_rect(rect),
|
||||
),
|
||||
@@ -53,7 +53,7 @@ impl LayerProvider for ProjectionLayer {
|
||||
.fov(openxr_views.0[1].fov)
|
||||
.sub_image(
|
||||
SwapchainSubImage::new()
|
||||
.swapchain(&swapchain)
|
||||
.swapchain(swapchain)
|
||||
.image_array_index(1)
|
||||
.image_rect(rect),
|
||||
),
|
||||
@@ -235,9 +235,15 @@ impl<'a> Default for CompositionLayerProjection<'a> {
|
||||
pub struct CompositionLayerPassthrough {
|
||||
inner: sys::CompositionLayerPassthroughFB,
|
||||
}
|
||||
impl Default for CompositionLayerPassthrough {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl CompositionLayerPassthrough {
|
||||
#[inline]
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
inner: openxr::sys::CompositionLayerPassthroughFB {
|
||||
ty: openxr::sys::CompositionLayerPassthroughFB::TYPE,
|
||||
|
||||
@@ -60,8 +60,8 @@ pub fn add_xr_plugins<G: PluginGroup>(plugins: G) -> PluginGroupBuilder {
|
||||
.build()
|
||||
.disable::<RenderPlugin>()
|
||||
// .disable::<PipelinedRenderingPlugin>()
|
||||
.add_before::<RenderPlugin, _>(XrSessionPlugin { auto_handle: true })
|
||||
.add_before::<RenderPlugin, _>(OxrInitPlugin::default())
|
||||
.add_before::<RenderPlugin>(XrSessionPlugin { auto_handle: true })
|
||||
.add_before::<RenderPlugin>(OxrInitPlugin::default())
|
||||
.add(OxrEventsPlugin)
|
||||
.add(OxrReferenceSpacePlugin::default())
|
||||
.add(OxrRenderPlugin)
|
||||
|
||||
@@ -150,16 +150,18 @@ pub fn init_views(
|
||||
info!("{}", graphics_info.resolution);
|
||||
let view_handle =
|
||||
add_texture_view(&mut manual_texture_views, temp_tex, &graphics_info, index);
|
||||
|
||||
let cam = commands
|
||||
.spawn((XrCameraBundle {
|
||||
camera: Camera {
|
||||
target: RenderTarget::TextureView(view_handle),
|
||||
.spawn(
|
||||
(XrCameraBundle {
|
||||
camera: Camera {
|
||||
target: RenderTarget::TextureView(view_handle),
|
||||
..Default::default()
|
||||
},
|
||||
view: XrCamera(index),
|
||||
..Default::default()
|
||||
},
|
||||
view: XrCamera(index),
|
||||
..Default::default()
|
||||
},))
|
||||
}),
|
||||
)
|
||||
.remove::<Projection>()
|
||||
.id();
|
||||
match root.get_single() {
|
||||
Ok(root) => {
|
||||
|
||||
@@ -43,6 +43,7 @@ impl OxrEntry {
|
||||
application_version: app_info.version.to_u32(),
|
||||
engine_name: "Bevy",
|
||||
engine_version: Version::BEVY.to_u32(),
|
||||
api_version: openxr::Version::new(1, 1, 36),
|
||||
},
|
||||
&required_exts.into(),
|
||||
layers,
|
||||
@@ -108,7 +109,7 @@ impl OxrInstance {
|
||||
graphics_match!(
|
||||
self.1;
|
||||
_ => {
|
||||
let (graphics, session_info) = Api::init_graphics(&self.2, &self, system_id)?;
|
||||
let (graphics, session_info) = Api::init_graphics(&self.2, self, system_id)?;
|
||||
|
||||
Ok((graphics, SessionCreateInfo(Api::wrap(session_info))))
|
||||
}
|
||||
@@ -185,7 +186,7 @@ impl OxrFrameStream {
|
||||
stream => {
|
||||
let mut new_layers = vec![];
|
||||
|
||||
for (i, layer) in layers.into_iter().enumerate() {
|
||||
for (i, layer) in layers.iter().enumerate() {
|
||||
if let Some(swapchain) = layer.swapchain() {
|
||||
if !swapchain.0.using_graphics::<Api>() {
|
||||
error!(
|
||||
@@ -196,7 +197,10 @@ impl OxrFrameStream {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
new_layers.push(unsafe { std::mem::transmute(layer.header()) });
|
||||
new_layers.push(unsafe {
|
||||
#[allow(clippy::missing_transmute_annotations)]
|
||||
std::mem::transmute(layer.header())
|
||||
});
|
||||
}
|
||||
|
||||
Ok(stream.end(display_time, environment_blend_mode, new_layers.as_slice())?)
|
||||
|
||||
@@ -7,7 +7,6 @@ use bevy_mod_xr::{
|
||||
XrDestroySpace, XrPrimaryReferenceSpace, XrReferenceSpace, XrSpace, XrSpaceLocationFlags,
|
||||
XrSpaceVelocityFlags, XrVelocity,
|
||||
},
|
||||
types::XrPose,
|
||||
};
|
||||
use openxr::{
|
||||
sys, HandJointLocation, HandJointLocations, HandJointVelocities, HandJointVelocity,
|
||||
@@ -51,28 +50,11 @@ impl Plugin for OxrSpatialPlugin {
|
||||
.in_set(OxrSpaceSyncSet)
|
||||
.run_if(openxr_session_running),
|
||||
)
|
||||
.observe(add_location_flags)
|
||||
.observe(add_velocity_flags);
|
||||
.register_required_components::<XrSpaceLocationFlags, OxrSpaceLocationFlags>()
|
||||
.register_required_components::<XrSpaceVelocityFlags, OxrSpaceVelocityFlags>();
|
||||
}
|
||||
}
|
||||
|
||||
fn add_velocity_flags(event: Trigger<OnAdd, XrVelocity>, mut cmds: Commands) {
|
||||
if event.entity() == Entity::PLACEHOLDER {
|
||||
error!("called add_location_flags observer without entity");
|
||||
return;
|
||||
}
|
||||
cmds.entity(event.entity())
|
||||
.insert(OxrSpaceLocationFlags(openxr::SpaceLocationFlags::default()));
|
||||
}
|
||||
fn add_location_flags(event: Trigger<OnAdd, XrSpace>, mut cmds: Commands) {
|
||||
if event.entity() == Entity::PLACEHOLDER {
|
||||
error!("called add_location_flags observer without entity");
|
||||
return;
|
||||
}
|
||||
cmds.entity(event.entity())
|
||||
.insert(OxrSpaceLocationFlags(openxr::SpaceLocationFlags::default()));
|
||||
}
|
||||
|
||||
fn destroy_space_event(instance: Res<OxrInstance>, mut events: EventReader<XrDestroySpace>) {
|
||||
for space in events.read() {
|
||||
match instance.destroy_space(space.0) {
|
||||
@@ -119,7 +101,7 @@ unsafe extern "system" fn patched_destroy_space(space: openxr::sys::Space) -> op
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Component)]
|
||||
#[derive(Clone, Copy, Component, Default)]
|
||||
pub struct OxrSpaceLocationFlags(pub openxr::SpaceLocationFlags);
|
||||
impl OxrSpaceLocationFlags {
|
||||
pub fn pos_valid(&self) -> bool {
|
||||
@@ -135,7 +117,7 @@ impl OxrSpaceLocationFlags {
|
||||
self.0.contains(SpaceLocationFlags::ORIENTATION_TRACKED)
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Copy, Component)]
|
||||
#[derive(Clone, Copy, Component, Default)]
|
||||
pub struct OxrSpaceVelocityFlags(pub openxr::SpaceVelocityFlags);
|
||||
impl OxrSpaceVelocityFlags {
|
||||
pub fn linear_valid(&self) -> bool {
|
||||
@@ -231,7 +213,7 @@ impl OxrSession {
|
||||
&self,
|
||||
action: &openxr::Action<T>,
|
||||
subaction_path: openxr::Path,
|
||||
pose_in_space: XrPose,
|
||||
pose_in_space: Isometry3d,
|
||||
) -> openxr::Result<XrSpace> {
|
||||
let info = sys::ActionSpaceCreateInfo {
|
||||
ty: sys::ActionSpaceCreateInfo::TYPE,
|
||||
|
||||
@@ -24,7 +24,7 @@ pub struct Version(pub u8, pub u8, pub u16);
|
||||
|
||||
impl Version {
|
||||
/// Bevy's version number
|
||||
pub const BEVY: Self = Self(0, 13, 0);
|
||||
pub const BEVY: Self = Self(0, 15, 0);
|
||||
|
||||
pub const fn to_u32(self) -> u32 {
|
||||
let major = (self.0 as u32) << 24;
|
||||
|
||||
Reference in New Issue
Block a user