remove point light from sessions example and other small changes
Signed-off-by: Schmarni <marnistromer@gmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@ fn main() {
|
|||||||
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
|
.add_plugins(bevy_xr_utils::hand_gizmos::HandGizmosPlugin)
|
||||||
.add_systems(Startup, setup)
|
.add_systems(Startup, setup)
|
||||||
.add_systems(Update, handle_input)
|
.add_systems(Update, handle_input)
|
||||||
|
.insert_resource(AmbientLight::default())
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,15 +63,6 @@ fn setup(
|
|||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..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 {
|
commands.spawn(Camera3dBundle {
|
||||||
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
|
transform: Transform::from_xyz(-2.5, 4.5, 9.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
..default()
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::{init::OxrPreUpdateSet, resources::OxrSession};
|
use crate::{init::OxrPreUpdateSet, session::OxrSession};
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_xr::session::session_running;
|
use bevy_xr::session::session_running;
|
||||||
|
|
||||||
|
|||||||
@@ -494,8 +494,6 @@ pub fn end_xr_session(session: Res<OxrSession>, session_started: Res<OxrSessionS
|
|||||||
session
|
session
|
||||||
.request_exit()
|
.request_exit()
|
||||||
.expect("Failed to request session 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.
|
/// 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_schedule(XrRenderSessionEnding);
|
||||||
world.run_system_once(apply_deferred);
|
world.run_system_once(apply_deferred);
|
||||||
if let Some(sess) = world.remove_resource::<OxrSession>() {
|
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 {
|
unsafe {
|
||||||
(sess.instance().fp().destroy_session)(sess.as_raw());
|
(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));
|
Box::leak(Box::new(sess));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ impl Plugin for OxrSessionPlugin {
|
|||||||
app.add_systems(XrSessionExiting, clean_session);
|
app.add_systems(XrSessionExiting, clean_session);
|
||||||
app.sub_app_mut(RenderApp)
|
app.sub_app_mut(RenderApp)
|
||||||
.add_systems(XrRenderSessionEnding, |mut cmds: Commands| {
|
.add_systems(XrRenderSessionEnding, |mut cmds: Commands| {
|
||||||
// cmds.remove_resource::<OxrSession>();
|
|
||||||
cmds.remove_resource::<OxrCleanupSession>();
|
cmds.remove_resource::<OxrCleanupSession>();
|
||||||
});
|
});
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
@@ -70,11 +69,7 @@ fn run_session_status_schedules(world: &mut World) {
|
|||||||
OxrSessionStatusEvent::AboutToBeDestroyed => {
|
OxrSessionStatusEvent::AboutToBeDestroyed => {
|
||||||
world.run_schedule(XrSessionExiting);
|
world.run_schedule(XrSessionExiting);
|
||||||
world.run_system_once(apply_deferred);
|
world.run_system_once(apply_deferred);
|
||||||
if let Some(sess) = world.remove_resource::<OxrSession>() {
|
world.remove_resource::<OxrSession>();
|
||||||
// unsafe {
|
|
||||||
// (sess.instance().fp().destroy_session)(sess.as_raw());
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user