refactor: cleanup for bevy 0.16

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2025-04-26 14:25:54 +02:00
parent ae54de3db9
commit 6284d4bf31
13 changed files with 46 additions and 84 deletions

View File

@@ -27,7 +27,7 @@ impl Plugin for OxrOverlayPlugin {
fn handle_overlay_event(event: OxrEventIn, mut writer: EventWriter<OxrOverlaySessionEvent>) {
if let Event::MainSessionVisibilityChangedEXTX(event) = *event {
writer.send(OxrOverlaySessionEvent::MainSessionVisibilityChanged {
writer.write(OxrOverlaySessionEvent::MainSessionVisibilityChanged {
visible: event.visible(),
flags: event.flags(),
});

View File

@@ -9,7 +9,7 @@ use crate::resources::*;
use crate::spaces::OxrSpaceExt as _;
pub trait LayerProvider {
fn get<'a>(&'a self, world: &'a World) -> Option<Box<dyn CompositionLayer + 'a>>;
fn get<'a>(&'a self, world: &'a World) -> Option<Box<dyn CompositionLayer<'a> + 'a>>;
}
pub struct ProjectionLayer;
@@ -117,7 +117,7 @@ impl<'a> SwapchainSubImage<'a> {
}
}
impl<'a> Default for SwapchainSubImage<'a> {
impl Default for SwapchainSubImage<'_> {
fn default() -> Self {
Self::new()
}
@@ -165,11 +165,15 @@ impl<'a> CompositionLayerProjectionView<'a> {
self
}
}
impl<'a> Default for CompositionLayerProjectionView<'a> {
impl Default for CompositionLayerProjectionView<'_> {
fn default() -> Self {
Self::new()
}
}
/// # Safety
/// the header function must return a ref to a valid Composition Layer struct.
/// it has to use `repr(C)` and it has to follow the shape of a Composition Layer struct from the
/// OpenXR specification
pub unsafe trait CompositionLayer<'a> {
fn swapchain(&self) -> Option<&'a OxrSwapchain>;
fn header(&self) -> &sys::CompositionLayerBaseHeader;
@@ -227,7 +231,7 @@ unsafe impl<'a> CompositionLayer<'a> for CompositionLayerProjection<'a> {
unsafe { mem::transmute(&self.inner) }
}
}
impl<'a> Default for CompositionLayerProjection<'a> {
impl Default for CompositionLayerProjection<'_> {
fn default() -> Self {
Self::new()
}

View File

@@ -20,18 +20,10 @@ impl Default for OxrReferenceSpacePlugin {
}
}
/// Resource specifying what the type should be for [`OxrPrimaryReferenceSpace`]. Set through [`OxrReferenceSpacePlugin`].
/// Resource specifying what the type should used be for the [`XrPrimaryReferenceSpace`]. Set through [`OxrReferenceSpacePlugin`].
#[derive(Resource)]
struct OxrDefaultPrimaryReferenceSpaceType(openxr::ReferenceSpaceType);
/// The Default Reference space used for locating things
// #[derive(Resource, Deref, ExtrctResource, Clone)]
// pub struct OxrPrimaryReferenceSpace(pub Arc<openxr::Space>);
/// The Reference space used for locating spaces on this entity
#[derive(Component)]
pub struct OxrReferenceSpace(pub openxr::Space);
impl Plugin for OxrReferenceSpacePlugin {
fn build(&self, app: &mut App) {
app.add_plugins(ExtractResourcePlugin::<XrPrimaryReferenceSpace>::default())

View File

@@ -1,4 +1,3 @@
use bevy::{
prelude::*,
render::{
@@ -251,7 +250,6 @@ pub fn update_views(
views: ResMut<OxrViews>,
) {
for (mut transform, mut projection, camera) in query.iter_mut() {
println!("we have this query");
let Some(view) = views.get(camera.0 as usize) else {
continue;
};
@@ -271,11 +269,6 @@ pub fn update_views(
);
projection.projection_matrix = projection_matrix;
println!(
"Updateing projectinon matrix to: {:#?}",
projection.projection_matrix
);
let openxr::Quaternionf { x, y, z, w } = view.pose.orientation;
let rotation = Quat::from_xyzw(x, y, z, w);
transform.rotation = rotation;

View File

@@ -288,10 +288,6 @@ impl OxrSwapchain {
#[derive(Debug, Deref, Resource, Clone, Copy, ExtractResource)]
pub struct OxrSwapchainImages(pub &'static [wgpu::Texture]);
/// Thread safe wrapper around [openxr::Space] representing the stage.
// #[derive(Deref, Clone, Resource)]
// pub struct OxrStage(pub Arc<openxr::Space>);
/// Stores the latest generated [OxrViews]
#[derive(Clone, Resource, ExtractResource, Deref, DerefMut, Default)]
pub struct OxrViews(pub Vec<openxr::View>);