add new XrSpace and impl that
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -3,3 +3,4 @@ pub mod camera;
|
||||
pub mod hands;
|
||||
pub mod session;
|
||||
pub mod types;
|
||||
pub mod spaces;
|
||||
|
||||
46
crates/bevy_xr/src/spaces.rs
Normal file
46
crates/bevy_xr/src/spaces.rs
Normal 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
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,13 @@
|
||||
use bevy::math::{Quat, Vec3};
|
||||
|
||||
pub struct Pose {
|
||||
pub struct XrPose {
|
||||
pub position: Vec3,
|
||||
pub orientation: Quat,
|
||||
pub rotation: Quat,
|
||||
}
|
||||
|
||||
impl XrPose {
|
||||
pub const IDENTITY: XrPose = XrPose {
|
||||
position: Vec3::ZERO,
|
||||
rotation: Quat::IDENTITY,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user