refactor: move OxrSpaceSyncSet into bevy_mod_xr and put locate_hands in the new XrSpaceSyncSet
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -6,8 +6,8 @@ use bevy_mod_xr::hands::{
|
|||||||
use bevy_mod_xr::hands::{LeftHand, RightHand, XrHandBoneEntities};
|
use bevy_mod_xr::hands::{LeftHand, RightHand, XrHandBoneEntities};
|
||||||
use bevy_mod_xr::session::{XrPreDestroySession, XrSessionCreated};
|
use bevy_mod_xr::session::{XrPreDestroySession, XrSessionCreated};
|
||||||
use bevy_mod_xr::spaces::{
|
use bevy_mod_xr::spaces::{
|
||||||
XrPrimaryReferenceSpace, XrReferenceSpace, XrSpaceLocationFlags, XrSpaceVelocityFlags,
|
XrPrimaryReferenceSpace, XrReferenceSpace, XrSpaceLocationFlags, XrSpaceSyncSet,
|
||||||
XrVelocity,
|
XrSpaceVelocityFlags, XrVelocity,
|
||||||
};
|
};
|
||||||
use openxr::{SpaceLocationFlags, SpaceVelocityFlags};
|
use openxr::{SpaceLocationFlags, SpaceVelocityFlags};
|
||||||
|
|
||||||
@@ -31,7 +31,12 @@ impl Default for HandTrackingPlugin {
|
|||||||
|
|
||||||
impl Plugin for HandTrackingPlugin {
|
impl Plugin for HandTrackingPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(PreUpdate, locate_hands.run_if(openxr_session_running));
|
app.add_systems(
|
||||||
|
PreUpdate,
|
||||||
|
locate_hands
|
||||||
|
.in_set(XrSpaceSyncSet)
|
||||||
|
.run_if(openxr_session_running),
|
||||||
|
);
|
||||||
if self.default_hands {
|
if self.default_hands {
|
||||||
app.add_systems(XrPreDestroySession, clean_up_default_hands)
|
app.add_systems(XrPreDestroySession, clean_up_default_hands)
|
||||||
.add_systems(XrSessionCreated, spawn_default_hands);
|
.add_systems(XrSessionCreated, spawn_default_hands);
|
||||||
|
|||||||
@@ -4,8 +4,7 @@ use bevy::{platform::collections::hash_set::HashSet, prelude::*};
|
|||||||
use bevy_mod_xr::{
|
use bevy_mod_xr::{
|
||||||
session::{XrFirst, XrHandleEvents},
|
session::{XrFirst, XrHandleEvents},
|
||||||
spaces::{
|
spaces::{
|
||||||
XrDestroySpace, XrPrimaryReferenceSpace, XrReferenceSpace, XrSpace, XrSpaceLocationFlags,
|
XrDestroySpace, XrPrimaryReferenceSpace, XrReferenceSpace, XrSpace, XrSpaceLocationFlags, XrSpaceSyncSet, XrSpaceVelocityFlags, XrVelocity
|
||||||
XrSpaceVelocityFlags, XrVelocity,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use openxr::{
|
use openxr::{
|
||||||
@@ -20,9 +19,6 @@ use crate::{
|
|||||||
session::OxrSession,
|
session::OxrSession,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(SystemSet, Hash, Debug, Clone, Copy, PartialEq, Eq)]
|
|
||||||
pub struct OxrSpaceSyncSet;
|
|
||||||
|
|
||||||
/// VERY IMPORTANT!! only disable when you know what you are doing
|
/// VERY IMPORTANT!! only disable when you know what you are doing
|
||||||
pub struct OxrSpacePatchingPlugin;
|
pub struct OxrSpacePatchingPlugin;
|
||||||
impl Plugin for OxrSpacePatchingPlugin {
|
impl Plugin for OxrSpacePatchingPlugin {
|
||||||
@@ -47,7 +43,7 @@ impl Plugin for OxrSpatialPlugin {
|
|||||||
.add_systems(
|
.add_systems(
|
||||||
PreUpdate,
|
PreUpdate,
|
||||||
update_space_transforms
|
update_space_transforms
|
||||||
.in_set(OxrSpaceSyncSet)
|
.in_set(XrSpaceSyncSet)
|
||||||
.run_if(openxr_session_running),
|
.run_if(openxr_session_running),
|
||||||
)
|
)
|
||||||
.register_required_components::<XrSpaceLocationFlags, OxrSpaceLocationFlags>()
|
.register_required_components::<XrSpaceLocationFlags, OxrSpaceLocationFlags>()
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ use bevy::{
|
|||||||
|
|
||||||
use crate::session::XrTracker;
|
use crate::session::XrTracker;
|
||||||
|
|
||||||
|
#[derive(SystemSet, Hash, Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
pub struct XrSpaceSyncSet;
|
||||||
|
|
||||||
/// Any Spaces will be invalid after the owning session exits
|
/// Any Spaces will be invalid after the owning session exits
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Component, Clone, Copy, Hash, PartialEq, Eq, Reflect, Debug, ExtractComponent)]
|
#[derive(Component, Clone, Copy, Hash, PartialEq, Eq, Reflect, Debug, ExtractComponent)]
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ use bevy_mod_openxr::{
|
|||||||
openxr_session_available, openxr_session_running,
|
openxr_session_available, openxr_session_running,
|
||||||
resources::{OxrFrameState, OxrInstance, Pipelined},
|
resources::{OxrFrameState, OxrInstance, Pipelined},
|
||||||
session::OxrSession,
|
session::OxrSession,
|
||||||
spaces::{OxrSpaceLocationFlags, OxrSpaceSyncSet},
|
spaces::OxrSpaceLocationFlags,
|
||||||
};
|
};
|
||||||
use bevy_mod_xr::{
|
use bevy_mod_xr::{
|
||||||
session::{XrSessionCreated, XrTracker, XrTrackingRoot},
|
session::{XrSessionCreated, XrTracker, XrTrackingRoot},
|
||||||
spaces::{XrPrimaryReferenceSpace, XrReferenceSpace},
|
spaces::{XrPrimaryReferenceSpace, XrReferenceSpace, XrSpaceSyncSet},
|
||||||
};
|
};
|
||||||
use openxr::Posef;
|
use openxr::Posef;
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ impl Plugin for TrackingUtilitiesPlugin {
|
|||||||
app.add_systems(
|
app.add_systems(
|
||||||
PreUpdate,
|
PreUpdate,
|
||||||
update_head_transforms
|
update_head_transforms
|
||||||
.in_set(OxrSpaceSyncSet)
|
.in_set(XrSpaceSyncSet)
|
||||||
.run_if(openxr_session_running),
|
.run_if(openxr_session_running),
|
||||||
);
|
);
|
||||||
//external
|
//external
|
||||||
@@ -73,8 +73,8 @@ impl Plugin for TrackingUtilitiesPlugin {
|
|||||||
//create actions
|
//create actions
|
||||||
app.add_systems(Startup, create_actions.run_if(openxr_session_available));
|
app.add_systems(Startup, create_actions.run_if(openxr_session_available));
|
||||||
|
|
||||||
app.add_systems(PreUpdate, update_left_grip.after(OxrSpaceSyncSet));
|
app.add_systems(PreUpdate, update_left_grip.after(XrSpaceSyncSet));
|
||||||
app.add_systems(PreUpdate, update_right_grip.after(OxrSpaceSyncSet));
|
app.add_systems(PreUpdate, update_right_grip.after(XrSpaceSyncSet));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user