remove XrSpatialTransform in favor of making XrSpace a Component and adding XrSpatialOffset
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -3,21 +3,19 @@ use bevy::{
|
||||
render::{extract_component::ExtractComponent, extract_resource::ExtractResource},
|
||||
};
|
||||
|
||||
use crate::types::XrPose;
|
||||
|
||||
/// Any Spaces will be invalid after the owning session exits
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, Hash, PartialEq, Eq, Reflect, Debug)]
|
||||
#[derive(Clone, Copy, Hash, PartialEq, Eq, Reflect, Debug, Component, ExtractComponent)]
|
||||
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 }
|
||||
}
|
||||
}
|
||||
// Does repr(transparent) even make sense here?
|
||||
#[repr(transparent)]
|
||||
#[derive(
|
||||
Clone, Copy, PartialEq, Reflect, Debug, Component, ExtractComponent, Default, Deref, DerefMut,
|
||||
)]
|
||||
pub struct XrSpatialOffset(pub XrPose);
|
||||
|
||||
#[derive(Event, Clone, Copy, Deref, DerefMut)]
|
||||
pub struct XrDestroySpace(pub XrSpace);
|
||||
|
||||
@@ -1,13 +1,26 @@
|
||||
use bevy::math::{Quat, Vec3};
|
||||
use bevy::{
|
||||
math::{Quat, Vec3},
|
||||
reflect::Reflect,
|
||||
transform::components::Transform,
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Reflect, Debug)]
|
||||
pub struct XrPose {
|
||||
pub position: Vec3,
|
||||
pub translation: Vec3,
|
||||
pub rotation: Quat,
|
||||
}
|
||||
|
||||
impl Default for XrPose {
|
||||
fn default() -> Self {
|
||||
Self::IDENTITY
|
||||
}
|
||||
}
|
||||
impl XrPose {
|
||||
pub const IDENTITY: XrPose = XrPose {
|
||||
position: Vec3::ZERO,
|
||||
translation: Vec3::ZERO,
|
||||
rotation: Quat::IDENTITY,
|
||||
};
|
||||
pub const fn to_transform(self) -> Transform {
|
||||
Transform::from_translation(self.translation).with_rotation(self.rotation)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user