add new XrSpace and impl that

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2024-06-15 15:37:01 +02:00
parent aa2a335074
commit 6003cc7ac6
15 changed files with 860 additions and 52 deletions

View File

@@ -0,0 +1,46 @@
use bevy::{
prelude::*,
render::{extract_component::ExtractComponent, extract_resource::ExtractResource},
};
/// Any Spaces will be invalid after the owning session exits
#[repr(transparent)]
#[derive(Clone, Copy, Hash, PartialEq, Eq, Reflect, Debug)]
pub struct XrSpace(u64);
#[derive(Clone, Copy, PartialEq, Reflect, Debug, Component, ExtractComponent)]
pub struct XrSpatialTransform {
pub space: XrSpace,
pub offset: Transform,
}
impl XrSpatialTransform {
pub const fn from_space(space: XrSpace) -> Self {
Self { space, offset: Transform::IDENTITY }
}
}
#[derive(Event, Clone, Copy, Deref, DerefMut)]
pub struct XrDestroySpace(pub XrSpace);
#[repr(transparent)]
#[derive(
Clone, Copy, Hash, PartialEq, Eq, Reflect, Debug, Component, Deref, DerefMut, ExtractComponent,
)]
pub struct XrReferenceSpace(pub XrSpace);
#[repr(transparent)]
#[derive(
Clone, Copy, Hash, PartialEq, Eq, Reflect, Debug, Resource, Deref, DerefMut, ExtractResource,
)]
pub struct XrPrimaryReferenceSpace(pub XrReferenceSpace);
impl XrSpace {
/// # Safety
/// only call with known valid handles
pub unsafe fn from_raw(handle: u64) -> Self {
Self(handle)
}
pub fn as_raw(&self) -> u64 {
self.0
}
}