This commit is contained in:
Schmarni
2024-01-27 04:06:27 +01:00
parent ac7c1089d9
commit 1e4db18f84
2 changed files with 7 additions and 21 deletions

View File

@@ -18,7 +18,9 @@ use bevy::app::{AppExit, PluginGroupBuilder};
use bevy::core::TaskPoolThreadAssignmentPolicy; use bevy::core::TaskPoolThreadAssignmentPolicy;
use bevy::ecs::system::SystemState; use bevy::ecs::system::SystemState;
use bevy::prelude::*; use bevy::prelude::*;
use bevy::render::camera::{ManualTextureView, ManualTextureViewHandle, ManualTextureViews}; use bevy::render::camera::{
camera_system, ManualTextureView, ManualTextureViewHandle, ManualTextureViews,
};
use bevy::render::extract_resource::ExtractResourcePlugin; use bevy::render::extract_resource::ExtractResourcePlugin;
use bevy::render::pipelined_rendering::PipelinedRenderingPlugin; use bevy::render::pipelined_rendering::PipelinedRenderingPlugin;
use bevy::render::renderer::{render_system, RenderInstance}; use bevy::render::renderer::{render_system, RenderInstance};
@@ -42,7 +44,7 @@ use xr_input::controllers::XrControllerType;
use xr_input::hands::emulated::HandEmulationPlugin; use xr_input::hands::emulated::HandEmulationPlugin;
use xr_input::hands::hand_tracking::{HandTrackingData, HandTrackingPlugin}; use xr_input::hands::hand_tracking::{HandTrackingData, HandTrackingPlugin};
use xr_input::hands::XrHandPlugins; use xr_input::hands::XrHandPlugins;
use xr_input::xr_camera::XrCameraType; use xr_input::xr_camera::{XRProjection, XrCameraType};
use xr_input::OpenXrInput; use xr_input::OpenXrInput;
const VIEW_TYPE: xr::ViewConfigurationType = xr::ViewConfigurationType::PRIMARY_STEREO; const VIEW_TYPE: xr::ViewConfigurationType = xr::ViewConfigurationType::PRIMARY_STEREO;
@@ -170,7 +172,7 @@ impl Plugin for OpenXrPlugin {
.run_if(xr_only()) .run_if(xr_only())
.run_if(xr_after_wait_only()) .run_if(xr_after_wait_only())
.run_if(xr_render_only()) .run_if(xr_render_only())
.after(RenderSet::Render), .in_set(RenderSet::Cleanup),
); );
render_app.add_systems( render_app.add_systems(
Render, Render,
@@ -178,7 +180,7 @@ impl Plugin for OpenXrPlugin {
.run_if(xr_only()) .run_if(xr_only())
.run_if(xr_after_wait_only()) .run_if(xr_after_wait_only())
.run_if(not(xr_render_only())) .run_if(not(xr_render_only()))
.after(RenderSet::Render), .in_set(RenderSet::Cleanup),
); );
} }
} }
@@ -219,8 +221,6 @@ impl PluginGroup for DefaultXrPlugins {
.set(TaskPoolPlugin { .set(TaskPoolPlugin {
task_pool_options: TaskPoolOptions { task_pool_options: TaskPoolOptions {
compute: TaskPoolThreadAssignmentPolicy { compute: TaskPoolThreadAssignmentPolicy {
// set the minimum # of compute threads
// to the total number of available threads
min_threads: 2, min_threads: 2,
max_threads: std::usize::MAX, // unlimited max threads max_threads: std::usize::MAX, // unlimited max threads
percent: 1.0, // this value is irrelevant in this case percent: 1.0, // this value is irrelevant in this case

View File

@@ -44,17 +44,15 @@ pub struct XrCameraBundle {
pub color_grading: ColorGrading, pub color_grading: ColorGrading,
pub xr_camera_type: XrCameraType, pub xr_camera_type: XrCameraType,
} }
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Component)] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd, Component, ExtractComponent)]
pub enum XrCameraType { pub enum XrCameraType {
Xr(Eye), Xr(Eye),
Flatscreen, Flatscreen,
} }
#[derive(Component)] #[derive(Component)]
pub(super) struct TransformExtract; pub(super) struct TransformExtract;
impl ExtractComponent for TransformExtract { impl ExtractComponent for TransformExtract {
type Query = Read<Transform>; type Query = Read<Transform>;
@@ -67,18 +65,6 @@ impl ExtractComponent for TransformExtract {
} }
} }
impl ExtractComponent for XrCameraType {
type Query = Read<Self>;
type Filter = ();
type Out = Self;
fn extract_component(item: bevy::ecs::query::QueryItem<'_, Self::Query>) -> Option<Self::Out> {
Some(*item)
}
}
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub enum Eye { pub enum Eye {
Left = 0, Left = 0,