From 6d515f3ae9d776042afb89c877168fa73b41a3d2 Mon Sep 17 00:00:00 2001 From: Schmarni Date: Fri, 17 Jan 2025 05:45:01 +0100 Subject: [PATCH] only add systems that depend on pbr when the PbrPlugin is added Signed-off-by: Schmarni --- crates/bevy_openxr/examples/actions.rs | 2 +- crates/bevy_xr/src/camera.rs | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/crates/bevy_openxr/examples/actions.rs b/crates/bevy_openxr/examples/actions.rs index eb7c6d9..81070f8 100644 --- a/crates/bevy_openxr/examples/actions.rs +++ b/crates/bevy_openxr/examples/actions.rs @@ -139,7 +139,7 @@ fn handle_flight_input( let view = views.first(); match view { Some(v) => { - let reference_quat = v.pose.orientation.to_quat(); + let reference_quat = root_position.rotation.inverse() * v.pose.orientation.to_quat(); let locomotion_vector = reference_quat.mul_vec3(input_vector); root_position.translation += diff --git a/crates/bevy_xr/src/camera.rs b/crates/bevy_xr/src/camera.rs index b779f51..e3b0250 100644 --- a/crates/bevy_xr/src/camera.rs +++ b/crates/bevy_xr/src/camera.rs @@ -6,9 +6,7 @@ use bevy::ecs::component::{Component, StorageType}; use bevy::ecs::reflect::ReflectComponent; use bevy::ecs::schedule::IntoSystemConfigs; use bevy::math::{Mat4, Vec3A}; -use bevy::pbr::{ - build_directional_light_cascades, clear_directional_light_cascades, SimulationLightSystems, -}; +use bevy::pbr::{PbrPlugin, PbrProjectionPlugin}; use bevy::prelude::Projection; use bevy::reflect::std_traits::ReflectDefault; use bevy::reflect::Reflect; @@ -30,12 +28,9 @@ impl Plugin for XrCameraPlugin { .after(TransformSystem::TransformPropagate) .before(VisibilitySystems::UpdateFrusta), ); - app.add_systems( - PostUpdate, - build_directional_light_cascades:: - .in_set(SimulationLightSystems::UpdateDirectionalLightCascades) - .after(clear_directional_light_cascades), - ); + if app.is_plugin_added::() { + app.add_plugins(PbrProjectionPlugin::::default()); + } app.add_plugins(( ExtractComponentPlugin::::default(), ExtractComponentPlugin::::default(),