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:
Schmarni
2025-05-02 14:58:54 +02:00
parent 84a69ea1ae
commit 4074d4be7c
4 changed files with 18 additions and 14 deletions

View File

@@ -6,8 +6,8 @@ use bevy_mod_xr::hands::{
use bevy_mod_xr::hands::{LeftHand, RightHand, XrHandBoneEntities};
use bevy_mod_xr::session::{XrPreDestroySession, XrSessionCreated};
use bevy_mod_xr::spaces::{
XrPrimaryReferenceSpace, XrReferenceSpace, XrSpaceLocationFlags, XrSpaceVelocityFlags,
XrVelocity,
XrPrimaryReferenceSpace, XrReferenceSpace, XrSpaceLocationFlags, XrSpaceSyncSet,
XrSpaceVelocityFlags, XrVelocity,
};
use openxr::{SpaceLocationFlags, SpaceVelocityFlags};
@@ -31,7 +31,12 @@ impl Default for HandTrackingPlugin {
impl Plugin for HandTrackingPlugin {
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 {
app.add_systems(XrPreDestroySession, clean_up_default_hands)
.add_systems(XrSessionCreated, spawn_default_hands);

View File

@@ -4,8 +4,7 @@ use bevy::{platform::collections::hash_set::HashSet, prelude::*};
use bevy_mod_xr::{
session::{XrFirst, XrHandleEvents},
spaces::{
XrDestroySpace, XrPrimaryReferenceSpace, XrReferenceSpace, XrSpace, XrSpaceLocationFlags,
XrSpaceVelocityFlags, XrVelocity,
XrDestroySpace, XrPrimaryReferenceSpace, XrReferenceSpace, XrSpace, XrSpaceLocationFlags, XrSpaceSyncSet, XrSpaceVelocityFlags, XrVelocity
},
};
use openxr::{
@@ -20,9 +19,6 @@ use crate::{
session::OxrSession,
};
#[derive(SystemSet, Hash, Debug, Clone, Copy, PartialEq, Eq)]
pub struct OxrSpaceSyncSet;
/// VERY IMPORTANT!! only disable when you know what you are doing
pub struct OxrSpacePatchingPlugin;
impl Plugin for OxrSpacePatchingPlugin {
@@ -47,7 +43,7 @@ impl Plugin for OxrSpatialPlugin {
.add_systems(
PreUpdate,
update_space_transforms
.in_set(OxrSpaceSyncSet)
.in_set(XrSpaceSyncSet)
.run_if(openxr_session_running),
)
.register_required_components::<XrSpaceLocationFlags, OxrSpaceLocationFlags>()