refactor: cleanup for bevy 0.16
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -21,8 +21,8 @@ fn main() {
|
|||||||
.add_systems(Update, handle_flight_input)
|
.add_systems(Update, handle_flight_input)
|
||||||
// Realtime lighting is expensive, use ambient light instead
|
// Realtime lighting is expensive, use ambient light instead
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
color: Default::default(),
|
|
||||||
brightness: 500.0,
|
brightness: 500.0,
|
||||||
|
..AmbientLight::default()
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
@@ -132,14 +132,15 @@ fn handle_flight_input(
|
|||||||
//hard code speed for now
|
//hard code speed for now
|
||||||
let speed = 5.0;
|
let speed = 5.0;
|
||||||
|
|
||||||
let root = oxr_root.get_single_mut();
|
let root = oxr_root.single_mut();
|
||||||
match root {
|
match root {
|
||||||
Ok(mut root_position) => {
|
Ok(mut root_position) => {
|
||||||
//lets assume HMD based direction for now
|
//lets assume HMD based direction for now
|
||||||
let view = views.first();
|
let view = views.first();
|
||||||
match view {
|
match view {
|
||||||
Some(v) => {
|
Some(v) => {
|
||||||
let reference_quat = root_position.rotation * v.pose.orientation.to_quat();
|
let reference_quat =
|
||||||
|
root_position.rotation * v.pose.orientation.to_quat();
|
||||||
let locomotion_vector = reference_quat.mul_vec3(input_vector);
|
let locomotion_vector = reference_quat.mul_vec3(input_vector);
|
||||||
|
|
||||||
root_position.translation +=
|
root_position.translation +=
|
||||||
|
|||||||
@@ -49,23 +49,23 @@ fn handle_input(
|
|||||||
) {
|
) {
|
||||||
if keys.just_pressed(KeyCode::KeyE) {
|
if keys.just_pressed(KeyCode::KeyE) {
|
||||||
info!("sending end");
|
info!("sending end");
|
||||||
end.send_default();
|
end.write_default();
|
||||||
}
|
}
|
||||||
if keys.just_pressed(KeyCode::KeyC) {
|
if keys.just_pressed(KeyCode::KeyC) {
|
||||||
info!("sending create");
|
info!("sending create");
|
||||||
create.send_default();
|
create.write_default();
|
||||||
}
|
}
|
||||||
if keys.just_pressed(KeyCode::KeyD) {
|
if keys.just_pressed(KeyCode::KeyD) {
|
||||||
info!("sending destroy");
|
info!("sending destroy");
|
||||||
destroy.send_default();
|
destroy.write_default();
|
||||||
}
|
}
|
||||||
if keys.just_pressed(KeyCode::KeyB) {
|
if keys.just_pressed(KeyCode::KeyB) {
|
||||||
info!("sending begin");
|
info!("sending begin");
|
||||||
begin.send_default();
|
begin.write_default();
|
||||||
}
|
}
|
||||||
if keys.just_pressed(KeyCode::KeyR) {
|
if keys.just_pressed(KeyCode::KeyR) {
|
||||||
info!("sending request exit");
|
info!("sending request exit");
|
||||||
request_exit.send_default();
|
request_exit.write_default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn attach_set(actions: Res<ControllerActions>, mut attach: EventWriter<OxrAttachActionSet>) {
|
fn attach_set(actions: Res<ControllerActions>, mut attach: EventWriter<OxrAttachActionSet>) {
|
||||||
attach.send(OxrAttachActionSet(actions.set.clone()));
|
attach.write(OxrAttachActionSet(actions.set.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
@@ -45,7 +45,7 @@ struct ControllerActions {
|
|||||||
right: openxr::Action<Posef>,
|
right: openxr::Action<Posef>,
|
||||||
}
|
}
|
||||||
fn sync_actions(actions: Res<ControllerActions>, mut sync: EventWriter<OxrSyncActionSet>) {
|
fn sync_actions(actions: Res<ControllerActions>, mut sync: EventWriter<OxrSyncActionSet>) {
|
||||||
sync.send(OxrSyncActionSet(actions.set.clone()));
|
sync.write(OxrSyncActionSet(actions.set.clone()));
|
||||||
}
|
}
|
||||||
/// set up a simple 3D scene
|
/// set up a simple 3D scene
|
||||||
fn setup(
|
fn setup(
|
||||||
@@ -82,12 +82,12 @@ fn suggest_action_bindings(
|
|||||||
actions: Res<ControllerActions>,
|
actions: Res<ControllerActions>,
|
||||||
mut bindings: EventWriter<OxrSuggestActionBinding>,
|
mut bindings: EventWriter<OxrSuggestActionBinding>,
|
||||||
) {
|
) {
|
||||||
bindings.send(OxrSuggestActionBinding {
|
bindings.write(OxrSuggestActionBinding {
|
||||||
action: actions.left.as_raw(),
|
action: actions.left.as_raw(),
|
||||||
interaction_profile: "/interaction_profiles/oculus/touch_controller".into(),
|
interaction_profile: "/interaction_profiles/oculus/touch_controller".into(),
|
||||||
bindings: vec!["/user/hand/left/input/grip/pose".into()],
|
bindings: vec!["/user/hand/left/input/grip/pose".into()],
|
||||||
});
|
});
|
||||||
bindings.send(OxrSuggestActionBinding {
|
bindings.write(OxrSuggestActionBinding {
|
||||||
action: actions.right.as_raw(),
|
action: actions.right.as_raw(),
|
||||||
interaction_profile: "/interaction_profiles/oculus/touch_controller".into(),
|
interaction_profile: "/interaction_profiles/oculus/touch_controller".into(),
|
||||||
bindings: vec!["/user/hand/right/input/grip/pose".into()],
|
bindings: vec!["/user/hand/right/input/grip/pose".into()],
|
||||||
|
|||||||
@@ -32,23 +32,23 @@ fn handle_input(
|
|||||||
) {
|
) {
|
||||||
if keys.just_pressed(KeyCode::KeyE) {
|
if keys.just_pressed(KeyCode::KeyE) {
|
||||||
info!("sending end");
|
info!("sending end");
|
||||||
end.send_default();
|
end.write_default();
|
||||||
}
|
}
|
||||||
if keys.just_pressed(KeyCode::KeyC) {
|
if keys.just_pressed(KeyCode::KeyC) {
|
||||||
info!("sending create");
|
info!("sending create");
|
||||||
create.send_default();
|
create.write_default();
|
||||||
}
|
}
|
||||||
if keys.just_pressed(KeyCode::KeyD) {
|
if keys.just_pressed(KeyCode::KeyD) {
|
||||||
info!("sending destroy");
|
info!("sending destroy");
|
||||||
destroy.send_default();
|
destroy.write_default();
|
||||||
}
|
}
|
||||||
if keys.just_pressed(KeyCode::KeyB) {
|
if keys.just_pressed(KeyCode::KeyB) {
|
||||||
info!("sending begin");
|
info!("sending begin");
|
||||||
begin.send_default();
|
begin.write_default();
|
||||||
}
|
}
|
||||||
if keys.just_pressed(KeyCode::KeyR) {
|
if keys.just_pressed(KeyCode::KeyR) {
|
||||||
info!("sending request exit");
|
info!("sending request exit");
|
||||||
request_exit.send_default();
|
request_exit.write_default();
|
||||||
}
|
}
|
||||||
if keys.just_pressed(KeyCode::KeyI) {
|
if keys.just_pressed(KeyCode::KeyI) {
|
||||||
info!("current state: {:?}", *state);
|
info!("current state: {:?}", *state);
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ fn main() {
|
|||||||
send_recenter.after(XRUtilsActionSystemSet::SyncActionStates),
|
send_recenter.after(XRUtilsActionSystemSet::SyncActionStates),
|
||||||
)
|
)
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
color: Default::default(),
|
|
||||||
brightness: 500.0,
|
brightness: 500.0,
|
||||||
|
..AmbientLight::default()
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
@@ -161,7 +161,7 @@ fn send_look_at_red_cube_event(
|
|||||||
info!("send facing");
|
info!("send facing");
|
||||||
let quat = Transform::default()
|
let quat = Transform::default()
|
||||||
.looking_at(Transform::from_xyz(4.0, 0.0, 0.0).translation, Vec3::Y); //this is a transform facing the red cube from the center of the scene, you should use the HMD posision but I was lazy.
|
.looking_at(Transform::from_xyz(4.0, 0.0, 0.0).translation, Vec3::Y); //this is a transform facing the red cube from the center of the scene, you should use the HMD posision but I was lazy.
|
||||||
event_writer.send(SnapToRotation(quat.rotation));
|
event_writer.write(SnapToRotation(quat.rotation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XRUtilsActionState::Float(_) => (),
|
XRUtilsActionState::Float(_) => (),
|
||||||
@@ -185,7 +185,7 @@ fn send_recenter(
|
|||||||
if send {
|
if send {
|
||||||
let center = Transform::default().translation;
|
let center = Transform::default().translation;
|
||||||
|
|
||||||
event_writer.send(SnapToPosition(center));
|
event_writer.write(SnapToPosition(center));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XRUtilsActionState::Float(_) => (),
|
XRUtilsActionState::Float(_) => (),
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ impl Plugin for OxrOverlayPlugin {
|
|||||||
|
|
||||||
fn handle_overlay_event(event: OxrEventIn, mut writer: EventWriter<OxrOverlaySessionEvent>) {
|
fn handle_overlay_event(event: OxrEventIn, mut writer: EventWriter<OxrOverlaySessionEvent>) {
|
||||||
if let Event::MainSessionVisibilityChangedEXTX(event) = *event {
|
if let Event::MainSessionVisibilityChangedEXTX(event) = *event {
|
||||||
writer.send(OxrOverlaySessionEvent::MainSessionVisibilityChanged {
|
writer.write(OxrOverlaySessionEvent::MainSessionVisibilityChanged {
|
||||||
visible: event.visible(),
|
visible: event.visible(),
|
||||||
flags: event.flags(),
|
flags: event.flags(),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ use crate::resources::*;
|
|||||||
use crate::spaces::OxrSpaceExt as _;
|
use crate::spaces::OxrSpaceExt as _;
|
||||||
|
|
||||||
pub trait LayerProvider {
|
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;
|
pub struct ProjectionLayer;
|
||||||
@@ -117,7 +117,7 @@ impl<'a> SwapchainSubImage<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Default for SwapchainSubImage<'a> {
|
impl Default for SwapchainSubImage<'_> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
@@ -165,11 +165,15 @@ impl<'a> CompositionLayerProjectionView<'a> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> Default for CompositionLayerProjectionView<'a> {
|
impl Default for CompositionLayerProjectionView<'_> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
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> {
|
pub unsafe trait CompositionLayer<'a> {
|
||||||
fn swapchain(&self) -> Option<&'a OxrSwapchain>;
|
fn swapchain(&self) -> Option<&'a OxrSwapchain>;
|
||||||
fn header(&self) -> &sys::CompositionLayerBaseHeader;
|
fn header(&self) -> &sys::CompositionLayerBaseHeader;
|
||||||
@@ -227,7 +231,7 @@ unsafe impl<'a> CompositionLayer<'a> for CompositionLayerProjection<'a> {
|
|||||||
unsafe { mem::transmute(&self.inner) }
|
unsafe { mem::transmute(&self.inner) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> Default for CompositionLayerProjection<'a> {
|
impl Default for CompositionLayerProjection<'_> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self::new()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)]
|
#[derive(Resource)]
|
||||||
struct OxrDefaultPrimaryReferenceSpaceType(openxr::ReferenceSpaceType);
|
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 {
|
impl Plugin for OxrReferenceSpacePlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_plugins(ExtractResourcePlugin::<XrPrimaryReferenceSpace>::default())
|
app.add_plugins(ExtractResourcePlugin::<XrPrimaryReferenceSpace>::default())
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
use bevy::{
|
use bevy::{
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{
|
render::{
|
||||||
@@ -251,7 +250,6 @@ pub fn update_views(
|
|||||||
views: ResMut<OxrViews>,
|
views: ResMut<OxrViews>,
|
||||||
) {
|
) {
|
||||||
for (mut transform, mut projection, camera) in query.iter_mut() {
|
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 {
|
let Some(view) = views.get(camera.0 as usize) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
@@ -271,11 +269,6 @@ pub fn update_views(
|
|||||||
);
|
);
|
||||||
projection.projection_matrix = projection_matrix;
|
projection.projection_matrix = projection_matrix;
|
||||||
|
|
||||||
println!(
|
|
||||||
"Updateing projectinon matrix to: {:#?}",
|
|
||||||
projection.projection_matrix
|
|
||||||
);
|
|
||||||
|
|
||||||
let openxr::Quaternionf { x, y, z, w } = view.pose.orientation;
|
let openxr::Quaternionf { x, y, z, w } = view.pose.orientation;
|
||||||
let rotation = Quat::from_xyzw(x, y, z, w);
|
let rotation = Quat::from_xyzw(x, y, z, w);
|
||||||
transform.rotation = rotation;
|
transform.rotation = rotation;
|
||||||
|
|||||||
@@ -288,10 +288,6 @@ impl OxrSwapchain {
|
|||||||
#[derive(Debug, Deref, Resource, Clone, Copy, ExtractResource)]
|
#[derive(Debug, Deref, Resource, Clone, Copy, ExtractResource)]
|
||||||
pub struct OxrSwapchainImages(pub &'static [wgpu::Texture]);
|
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]
|
/// Stores the latest generated [OxrViews]
|
||||||
#[derive(Clone, Resource, ExtractResource, Deref, DerefMut, Default)]
|
#[derive(Clone, Resource, ExtractResource, Deref, DerefMut, Default)]
|
||||||
pub struct OxrViews(pub Vec<openxr::View>);
|
pub struct OxrViews(pub Vec<openxr::View>);
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
use core::panic;
|
use core::panic;
|
||||||
|
|
||||||
use bevy::app::{App, Plugin, PostUpdate};
|
use bevy::app::{App, Plugin};
|
||||||
use bevy::core_pipeline::core_3d::Camera3d;
|
use bevy::core_pipeline::core_3d::Camera3d;
|
||||||
use bevy::ecs::component::{Component, HookContext, Mutable, StorageType};
|
use bevy::ecs::component::Component;
|
||||||
use bevy::ecs::reflect::ReflectComponent;
|
|
||||||
use bevy::ecs::world::DeferredWorld;
|
|
||||||
use bevy::math::{Mat4, Vec3A, Vec4};
|
use bevy::math::{Mat4, Vec3A, Vec4};
|
||||||
use bevy::pbr::{PbrPlugin, PbrProjectionPlugin};
|
use bevy::prelude::SystemSet;
|
||||||
use bevy::prelude::{Projection, SystemSet};
|
|
||||||
use bevy::reflect::std_traits::ReflectDefault;
|
use bevy::reflect::std_traits::ReflectDefault;
|
||||||
use bevy::reflect::Reflect;
|
use bevy::reflect::Reflect;
|
||||||
use bevy::render::camera::{CameraProjection, CameraProjectionPlugin, CustomProjection};
|
use bevy::render::camera::CameraProjection;
|
||||||
use bevy::render::extract_component::{ExtractComponent, ExtractComponentPlugin};
|
use bevy::render::extract_component::{ExtractComponent, ExtractComponentPlugin};
|
||||||
use bevy::render::view::{update_frusta, VisibilitySystems};
|
|
||||||
use bevy::transform::TransformSystem;
|
|
||||||
|
|
||||||
use crate::session::XrTracker;
|
use crate::session::XrTracker;
|
||||||
|
|
||||||
@@ -21,17 +16,7 @@ pub struct XrCameraPlugin;
|
|||||||
|
|
||||||
impl Plugin for XrCameraPlugin {
|
impl Plugin for XrCameraPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
/*app.add_plugins(CameraProjectionPlugin::<XrProjection>::default());
|
app.add_plugins(ExtractComponentPlugin::<XrCamera>::default());
|
||||||
app.add_systems(
|
|
||||||
PostUpdate,
|
|
||||||
update_frusta::<XrProjection>
|
|
||||||
.after(TransformSystem::TransformPropagate)
|
|
||||||
.before(VisibilitySystems::UpdateFrusta),
|
|
||||||
);
|
|
||||||
if app.is_plugin_added::<PbrPlugin>() {
|
|
||||||
app.add_plugins(PbrProjectionPlugin::<XrProjection>::default());
|
|
||||||
}*/
|
|
||||||
app.add_plugins((ExtractComponentPlugin::<XrCamera>::default(),));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,10 +30,6 @@ pub struct XrProjection {
|
|||||||
pub near: f32,
|
pub near: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_projection_add(mut world: DeferredWorld, HookContext { entity, .. }: HookContext) {
|
|
||||||
world.commands().entity(entity).remove::<Projection>();
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for XrProjection {
|
impl Default for XrProjection {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
@@ -124,7 +105,6 @@ pub fn calculate_projection(near_z: f32, fov: Fov) -> Mat4 {
|
|||||||
// let y_fov = (self.fov.angle_up.abs() + self.fov.angle_down.abs());
|
// let y_fov = (self.fov.angle_up.abs() + self.fov.angle_down.abs());
|
||||||
// return Mat4::perspective_infinite_reverse_rh(y_fov, x_fov / y_fov, self.near);
|
// return Mat4::perspective_infinite_reverse_rh(y_fov, x_fov / y_fov, self.near);
|
||||||
|
|
||||||
let is_vulkan_api = false; // FIXME wgpu probably abstracts this
|
|
||||||
let far_z = -1.; // use infinite proj
|
let far_z = -1.; // use infinite proj
|
||||||
// let far_z = self.far;
|
// let far_z = self.far;
|
||||||
|
|
||||||
@@ -141,11 +121,7 @@ pub fn calculate_projection(near_z: f32, fov: Fov) -> Mat4 {
|
|||||||
// positive Y up (OpenGL / D3D / Metal).
|
// positive Y up (OpenGL / D3D / Metal).
|
||||||
// const float tanAngleHeight =
|
// const float tanAngleHeight =
|
||||||
// graphicsApi == GRAPHICS_VULKAN ? (tanAngleDown - tanAngleUp) : (tanAngleUp - tanAngleDown);
|
// graphicsApi == GRAPHICS_VULKAN ? (tanAngleDown - tanAngleUp) : (tanAngleUp - tanAngleDown);
|
||||||
let tan_angle_height = if is_vulkan_api {
|
let tan_angle_height = tan_angle_up - tan_angle_down;
|
||||||
tan_angle_down - tan_angle_up
|
|
||||||
} else {
|
|
||||||
tan_angle_up - tan_angle_down
|
|
||||||
};
|
|
||||||
|
|
||||||
// Set to nearZ for a [-1,1] Z clip space (OpenGL / OpenGL ES).
|
// Set to nearZ for a [-1,1] Z clip space (OpenGL / OpenGL ES).
|
||||||
// Set to zero for a [0,1] Z clip space (Vulkan / D3D / Metal).
|
// Set to zero for a [0,1] Z clip space (Vulkan / D3D / Metal).
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::sync::atomic::AtomicBool;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use bevy::app::{AppExit, MainScheduleOrder};
|
use bevy::app::{AppExit, MainScheduleOrder};
|
||||||
use bevy::ecs::component::{HookContext, Mutable, StorageType};
|
use bevy::ecs::component::HookContext;
|
||||||
use bevy::ecs::schedule::ScheduleLabel;
|
use bevy::ecs::schedule::ScheduleLabel;
|
||||||
use bevy::ecs::world::DeferredWorld;
|
use bevy::ecs::world::DeferredWorld;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
@@ -216,7 +216,7 @@ impl Plugin for XrSessionPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn exits_session_on_app_exit(mut request_exit: EventWriter<XrRequestExitEvent>) {
|
fn exits_session_on_app_exit(mut request_exit: EventWriter<XrRequestExitEvent>) {
|
||||||
request_exit.send_default();
|
request_exit.write_default();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Event sent by backends whenever [`XrState`] is changed.
|
/// Event sent by backends whenever [`XrState`] is changed.
|
||||||
@@ -258,18 +258,18 @@ pub fn auto_handle_session(
|
|||||||
match state {
|
match state {
|
||||||
XrState::Available => {
|
XrState::Available => {
|
||||||
if !*no_auto_restart {
|
if !*no_auto_restart {
|
||||||
create_session.send_default();
|
create_session.write_default();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
XrState::Ready => {
|
XrState::Ready => {
|
||||||
begin_session.send_default();
|
begin_session.write_default();
|
||||||
}
|
}
|
||||||
XrState::Stopping => {
|
XrState::Stopping => {
|
||||||
end_session.send_default();
|
end_session.write_default();
|
||||||
}
|
}
|
||||||
XrState::Exiting { should_restart } => {
|
XrState::Exiting { should_restart } => {
|
||||||
*no_auto_restart = !should_restart;
|
*no_auto_restart = !should_restart;
|
||||||
destroy_session.send_default();
|
destroy_session.write_default();
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ pub fn update_root_transform(
|
|||||||
mut root_transform: ResMut<XrRootTransform>,
|
mut root_transform: ResMut<XrRootTransform>,
|
||||||
root: Query<&GlobalTransform, With<XrTrackingRoot>>,
|
root: Query<&GlobalTransform, With<XrTrackingRoot>>,
|
||||||
) {
|
) {
|
||||||
let Ok(transform) = root.get_single() else {
|
let Ok(transform) = root.single() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ pub fn handle_transform_events(
|
|||||||
}
|
}
|
||||||
|
|
||||||
//rotation
|
//rotation
|
||||||
let root_local = root_transform.translation.clone();
|
let root_local = root_transform.translation;
|
||||||
let hmd_global =
|
let hmd_global =
|
||||||
root_transform.rotation.mul_vec3(view_translation) + root_local;
|
root_transform.rotation.mul_vec3(view_translation) + root_local;
|
||||||
let view_rot = view.pose.orientation.to_quat();
|
let view_rot = view.pose.orientation.to_quat();
|
||||||
|
|||||||
Reference in New Issue
Block a user