session ending works but segfaults on my machine
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -12,11 +12,10 @@ use bevy::{
|
||||
};
|
||||
use bevy_xr::{
|
||||
camera::{XrCamera, XrCameraBundle, XrProjection},
|
||||
session::session_running,
|
||||
session::{session_running, XrSessionExiting},
|
||||
};
|
||||
use openxr::ViewStateFlags;
|
||||
|
||||
|
||||
use crate::{
|
||||
init::{session_started, OxrPreUpdateSet, OxrTrackingRoot},
|
||||
layer_builder::ProjectionLayer, session::OxrSession,
|
||||
@@ -45,7 +44,8 @@ impl Plugin for OxrRenderPlugin {
|
||||
.run_if(session_running)
|
||||
.before(TransformSystem::TransformPropagate),
|
||||
)
|
||||
.add_systems(Last, wait_frame.run_if(session_started));
|
||||
.add_systems(Last, wait_frame.run_if(session_started))
|
||||
.add_systems(XrSessionExiting, clean_views);
|
||||
app.sub_app_mut(RenderApp)
|
||||
.add_systems(
|
||||
Render,
|
||||
@@ -73,6 +73,17 @@ impl Plugin for OxrRenderPlugin {
|
||||
|
||||
pub const XR_TEXTURE_INDEX: u32 = 3383858418;
|
||||
|
||||
pub fn clean_views(
|
||||
mut manual_texture_views: ResMut<ManualTextureViews>,
|
||||
mut commands: Commands,
|
||||
cam_query: Query<(Entity, &XrCamera)>,
|
||||
) {
|
||||
for (e, cam) in &cam_query {
|
||||
manual_texture_views.remove(&ManualTextureViewHandle(XR_TEXTURE_INDEX + cam.0));
|
||||
commands.entity(e).despawn_recursive();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: have cameras initialized externally and then recieved by this function.
|
||||
/// This is needed to properly initialize the texture views so that bevy will set them to the correct resolution despite them being updated in the render world.
|
||||
pub fn init_views(
|
||||
|
||||
Reference in New Issue
Block a user