0.16 support

This commit is contained in:
Malek
2025-03-06 17:59:51 -05:00
committed by Schmarni
parent 9f6f5c0711
commit 4528529417
18 changed files with 1548 additions and 987 deletions

View File

@@ -1,10 +1,11 @@
use bevy::render::camera::CustomProjection;
use bevy::{
prelude::*,
render::{
camera::{ManualTextureView, ManualTextureViewHandle, ManualTextureViews, RenderTarget},
extract_resource::ExtractResourcePlugin,
pipelined_rendering::PipelinedRenderingPlugin,
view::ExtractedView,
view::{ExtractedView, NoFrustumCulling},
Render, RenderApp,
},
transform::TransformSystem,
@@ -170,6 +171,8 @@ pub fn init_views<const SPAWN_CAMERAS: bool>(
..Default::default()
},
XrCamera(index),
Projection::custom(XrProjection::default()),
NoFrustumCulling,
));
}
}
@@ -244,13 +247,18 @@ pub fn locate_views(
}
pub fn update_views(
mut query: Query<(&mut Transform, &mut XrProjection, &XrCamera)>,
mut query: Query<(&mut Transform, &mut Projection, &XrCamera)>,
views: ResMut<OxrViews>,
) {
for (mut transform, mut projection, camera) in query.iter_mut() {
println!("we have this query");
let Some(view) = views.get(camera.0 as usize) else {
continue;
};
let projection = match projection.as_mut() {
Projection::Custom(custom) => custom.get_mut::<XrProjection>().unwrap(),
_ => unreachable!(),
};
let projection_matrix = calculate_projection(
projection.near,
@@ -263,6 +271,11 @@ pub fn update_views(
);
projection.projection_matrix = projection_matrix;
println!(
"Updateing projectinon matrix to: {:#?}",
projection.projection_matrix
);
let openxr::Quaternionf { x, y, z, w } = view.pose.orientation;
let rotation = Quat::from_xyzw(x, y, z, w);
transform.rotation = rotation;