remove point light from sessions example and other small changes

Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
Schmarni
2024-05-30 11:14:03 +02:00
parent 5f5fd152bb
commit 40c767c2d2
4 changed files with 8 additions and 18 deletions

View File

@@ -10,6 +10,7 @@ fn main() {
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
.add_systems(Startup, setup)
.add_systems(Update, handle_input)
.insert_resource(AmbientLight::default())
.run();
}
@@ -62,15 +63,6 @@ fn setup(
transform: Transform::from_xyz(0.0, 0.5, 0.0),
..default()
});
// light
commands.spawn(PointLightBundle {
point_light: PointLight {
shadows_enabled: true,
..default()
},
transform: Transform::from_xyz(4.0, 8.0, 4.0),
..default()
});
commands.spawn(Camera3dBundle {
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
..default()

View File

@@ -1,4 +1,4 @@
use crate::{init::OxrPreUpdateSet, resources::OxrSession};
use crate::{init::OxrPreUpdateSet, session::OxrSession};
use bevy::prelude::*;
use bevy_xr::session::session_running;

View File

@@ -494,8 +494,6 @@ pub fn end_xr_session(session: Res<OxrSession>, session_started: Res<OxrSessionS
session
.request_exit()
.expect("Failed to request session exit");
// session.end().expect("Failed to end session");
// session_started.set(false);
}
/// This system transfers important render resources from the main world to the render world when a session is created.
@@ -588,9 +586,14 @@ pub fn destroy_xr_session_render(world: &mut World) {
world.run_schedule(XrRenderSessionEnding);
world.run_system_once(apply_deferred);
if let Some(sess) = world.remove_resource::<OxrSession>() {
// This is needed because there is one space that survives the session exit schedule and
// holds on to the session. this causes an error message but does not seem to cause any
// actuall issues.
unsafe {
(sess.instance().fp().destroy_session)(sess.as_raw());
}
// leaking the session so that it does not call destroy_session at a later point. might not
// actually be needed.
Box::leak(Box::new(sess));
}
}

View File

@@ -33,7 +33,6 @@ impl Plugin for OxrSessionPlugin {
app.add_systems(XrSessionExiting, clean_session);
app.sub_app_mut(RenderApp)
.add_systems(XrRenderSessionEnding, |mut cmds: Commands| {
// cmds.remove_resource::<OxrSession>();
cmds.remove_resource::<OxrCleanupSession>();
});
app.add_systems(
@@ -70,11 +69,7 @@ fn run_session_status_schedules(world: &mut World) {
OxrSessionStatusEvent::AboutToBeDestroyed => {
world.run_schedule(XrSessionExiting);
world.run_system_once(apply_deferred);
if let Some(sess) = world.remove_resource::<OxrSession>() {
// unsafe {
// (sess.instance().fp().destroy_session)(sess.as_raw());
// }
}
world.remove_resource::<OxrSession>();
}
}
}