only try to sync the space poses when the session is running

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2024-06-27 03:09:47 +02:00
parent 1feab741b6
commit 7abed765a5

View File

@@ -2,7 +2,7 @@ use std::{mem::MaybeUninit, ptr, sync::Mutex};
use bevy::{prelude::*, utils::hashbrown::HashSet};
use bevy_xr::{
session::{session_available, XrSessionExiting},
session::{session_available, session_running, XrSessionExiting},
spaces::{XrDestroySpace, XrPrimaryReferenceSpace, XrReferenceSpace, XrSpace, XrSpatialOffset},
types::XrPose,
};
@@ -34,7 +34,12 @@ impl Plugin for OxrSpatialPlugin {
app.add_event::<XrDestroySpace>();
app.add_systems(OxrLast, destroy_space_event.before(OxrHandleEvents));
app.add_systems(XrSessionExiting, destroy_space_components);
app.add_systems(PreUpdate, update_space_transforms.in_set(OxrSpaceSyncSet));
app.add_systems(
PreUpdate,
update_space_transforms
.in_set(OxrSpaceSyncSet)
.run_if(session_running),
);
}
}