fix(openxr): Z order
This commit is contained in:
@@ -80,7 +80,7 @@ impl LinePool {
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
data.data.sort_order = 69;
|
||||
data.state.z_order = 69;
|
||||
data.state.dirty = true;
|
||||
|
||||
self.lines.insert(id, data);
|
||||
|
||||
@@ -11,7 +11,6 @@ use vulkano::{Handle, VulkanObject};
|
||||
use crate::{
|
||||
backend::overlay::{OverlayData, RelativeTo},
|
||||
graphics::WlxGraphics,
|
||||
overlays::{anchor::ANCHOR_NAME, watch::WATCH_NAME},
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
@@ -23,7 +22,6 @@ pub(super) struct OpenVrOverlayData {
|
||||
pub(super) last_image: Option<u64>,
|
||||
pub(super) visible: bool,
|
||||
pub(super) color: Vec4,
|
||||
pub(super) sort_order: u32,
|
||||
pub(crate) width: f32,
|
||||
pub(super) override_width: bool,
|
||||
pub(super) relative_to: RelativeTo,
|
||||
@@ -45,15 +43,6 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
};
|
||||
log::debug!("{}: initialize", self.state.name);
|
||||
|
||||
//watch
|
||||
if *self.state.name == *WATCH_NAME {
|
||||
self.data.sort_order = 68;
|
||||
}
|
||||
|
||||
if *self.state.name == *ANCHOR_NAME.as_ref() {
|
||||
self.data.sort_order = 67;
|
||||
}
|
||||
|
||||
self.data.handle = Some(handle);
|
||||
self.data.color = Vec4::ONE;
|
||||
|
||||
@@ -193,7 +182,7 @@ impl OverlayData<OpenVrOverlayData> {
|
||||
log::debug!("{}: No overlay handle", self.state.name);
|
||||
return;
|
||||
};
|
||||
if let Err(e) = overlay.set_sort_order(handle, self.data.sort_order) {
|
||||
if let Err(e) = overlay.set_sort_order(handle, self.state.z_order) {
|
||||
log::error!("{}: Failed to set overlay z order: {}", self.state.name, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,6 +88,7 @@ pub(super) fn init_xr() -> Result<(xr::Instance, xr::SystemId), anyhow::Error> {
|
||||
|
||||
Ok((xr_instance, system))
|
||||
}
|
||||
|
||||
pub(super) unsafe fn create_overlay_session(
|
||||
instance: &xr::Instance,
|
||||
system: xr::SystemId,
|
||||
|
||||
@@ -148,7 +148,6 @@ impl LinePool {
|
||||
1.0,
|
||||
)?)
|
||||
.eye_visibility(xr::EyeVisibility::BOTH)
|
||||
.layer_flags(xr::CompositionLayerFlags::CORRECT_CHROMATIC_ABERRATION)
|
||||
.space(&xr.stage)
|
||||
.size(xr::Extent2Df {
|
||||
width: LINE_WIDTH,
|
||||
|
||||
@@ -289,7 +289,8 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
o.render(&mut app_state)?;
|
||||
|
||||
let dist_sq = (app_state.input_state.hmd.translation - o.state.transform.translation)
|
||||
.length_squared();
|
||||
.length_squared()
|
||||
+ (100f32 - o.state.z_order as f32);
|
||||
|
||||
if !dist_sq.is_normal() {
|
||||
continue;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use glam::Vec3A;
|
||||
use openxr as xr;
|
||||
use std::{f32::consts::PI, sync::Arc};
|
||||
use xr::{CompositionLayerFlags, EyeVisibility};
|
||||
use xr::EyeVisibility;
|
||||
|
||||
use super::{helpers, swapchain::SwapchainRenderData, CompositionLayer, XrState};
|
||||
use crate::{
|
||||
@@ -78,7 +78,6 @@ impl OverlayData<OpenXrOverlayData> {
|
||||
.pose(posef)
|
||||
.sub_image(sub_image)
|
||||
.eye_visibility(EyeVisibility::BOTH)
|
||||
.layer_flags(CompositionLayerFlags::CORRECT_CHROMATIC_ABERRATION)
|
||||
.space(&xr.stage)
|
||||
.radius(radius)
|
||||
.central_angle(angle)
|
||||
@@ -90,7 +89,6 @@ impl OverlayData<OpenXrOverlayData> {
|
||||
.pose(posef)
|
||||
.sub_image(sub_image)
|
||||
.eye_visibility(EyeVisibility::BOTH)
|
||||
.layer_flags(CompositionLayerFlags::CORRECT_CHROMATIC_ABERRATION)
|
||||
.space(&xr.stage)
|
||||
.size(xr::Extent2Df {
|
||||
width: scale_x,
|
||||
|
||||
@@ -32,6 +32,7 @@ pub struct OverlayState {
|
||||
pub anchored: bool,
|
||||
pub dirty: bool,
|
||||
pub alpha: f32,
|
||||
pub z_order: u32,
|
||||
pub transform: Affine3A,
|
||||
pub spawn_scale: f32, // aka width
|
||||
pub spawn_point: Vec3A,
|
||||
@@ -57,6 +58,7 @@ impl Default for OverlayState {
|
||||
anchored: false,
|
||||
dirty: true,
|
||||
alpha: 1.0,
|
||||
z_order: 0,
|
||||
relative_to: RelativeTo::None,
|
||||
curvature: None,
|
||||
spawn_scale: 1.0,
|
||||
|
||||
@@ -21,6 +21,7 @@ where
|
||||
want_visible: false,
|
||||
interactable: false,
|
||||
grabbable: false,
|
||||
z_order: 67,
|
||||
spawn_scale: config.width,
|
||||
spawn_point: Vec3A::NEG_Z * 0.5,
|
||||
..Default::default()
|
||||
|
||||
@@ -199,6 +199,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<(OverlayState, Box<dyn
|
||||
spawn_scale: size.0 * PIXELS_TO_METERS,
|
||||
spawn_rotation,
|
||||
spawn_point,
|
||||
z_order: 70,
|
||||
relative_to,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
@@ -25,6 +25,7 @@ where
|
||||
name: WATCH_NAME.into(),
|
||||
want_visible: true,
|
||||
interactable: true,
|
||||
z_order: 68,
|
||||
spawn_scale: config.width,
|
||||
spawn_point: state.session.config.watch_pos,
|
||||
spawn_rotation: state.session.config.watch_rot,
|
||||
|
||||
Reference in New Issue
Block a user