openxr: hide watch via transform
This commit is contained in:
@@ -29,7 +29,7 @@ use crate::{
|
|||||||
osc::OscSender,
|
osc::OscSender,
|
||||||
},
|
},
|
||||||
graphics::WlxGraphics,
|
graphics::WlxGraphics,
|
||||||
overlays::watch::watch_fade,
|
overlays::watch::{watch_fade, WATCH_NAME},
|
||||||
state::AppState,
|
state::AppState,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -117,6 +117,8 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
|||||||
|
|
||||||
log::info!("HMD running @ {} Hz", refresh_rate);
|
log::info!("HMD running @ {} Hz", refresh_rate);
|
||||||
|
|
||||||
|
let watch_id = overlays.get_by_name(WATCH_NAME).unwrap().state.id;
|
||||||
|
|
||||||
let frame_time = (1000.0 / refresh_rate).floor() * 0.001;
|
let frame_time = (1000.0 / refresh_rate).floor() * 0.001;
|
||||||
let mut next_device_update = Instant::now();
|
let mut next_device_update = Instant::now();
|
||||||
let mut due_tasks = VecDeque::with_capacity(4);
|
let mut due_tasks = VecDeque::with_capacity(4);
|
||||||
@@ -183,7 +185,7 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
|||||||
.iter_mut()
|
.iter_mut()
|
||||||
.for_each(|o| o.state.auto_movement(&mut state));
|
.for_each(|o| o.state.auto_movement(&mut state));
|
||||||
|
|
||||||
watch_fade(&mut state, &mut overlays);
|
watch_fade(&mut state, overlays.mut_by_id(watch_id).unwrap());
|
||||||
space_mover.update(&mut chaperone_mgr, &mut overlays, &state);
|
space_mover.update(&mut chaperone_mgr, &mut overlays, &state);
|
||||||
|
|
||||||
let lengths_haptics = interact(&mut overlays, &mut state);
|
let lengths_haptics = interact(&mut overlays, &mut state);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use std::{
|
|||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use glam::Affine3A;
|
use glam::{Affine3A, Vec3};
|
||||||
use openxr as xr;
|
use openxr as xr;
|
||||||
use vulkano::{command_buffer::CommandBufferUsage, Handle, VulkanObject};
|
use vulkano::{command_buffer::CommandBufferUsage, Handle, VulkanObject};
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ use crate::{
|
|||||||
osc::OscSender,
|
osc::OscSender,
|
||||||
},
|
},
|
||||||
graphics::WlxGraphics,
|
graphics::WlxGraphics,
|
||||||
overlays::watch::watch_fade,
|
overlays::watch::{watch_fade, WATCH_NAME},
|
||||||
state::AppState,
|
state::AppState,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -107,6 +107,8 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
|||||||
lines.allocate(&xr_state, app_state.graphics.clone()),
|
lines.allocate(&xr_state, app_state.graphics.clone()),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let watch_id = overlays.get_by_name(WATCH_NAME).unwrap().state.id;
|
||||||
|
|
||||||
let input_source = input::OpenXrInputSource::new(&xr_state);
|
let input_source = input::OpenXrInputSource::new(&xr_state);
|
||||||
|
|
||||||
let mut session_running = false;
|
let mut session_running = false;
|
||||||
@@ -212,7 +214,7 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch_fade(&mut app_state, &mut overlays);
|
watch_fade(&mut app_state, overlays.mut_by_id(watch_id).unwrap());
|
||||||
|
|
||||||
overlays
|
overlays
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
@@ -252,6 +254,17 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let watch = overlays.mut_by_id(watch_id).unwrap();
|
||||||
|
let watch_transform = watch.state.transform;
|
||||||
|
if !watch.state.want_visible {
|
||||||
|
watch.state.want_visible = true;
|
||||||
|
watch.state.transform = Affine3A::from_scale(Vec3 {
|
||||||
|
x: 0.001,
|
||||||
|
y: 0.001,
|
||||||
|
z: 0.001,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let mut layers = vec![];
|
let mut layers = vec![];
|
||||||
let mut command_buffer = app_state
|
let mut command_buffer = app_state
|
||||||
.graphics
|
.graphics
|
||||||
@@ -281,17 +294,6 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if layers.is_empty() && lines.num_pending() == 0 {
|
|
||||||
// HACK: we need to submit at least 1 layer, else the session hangs
|
|
||||||
lines.draw_from(
|
|
||||||
pointer_lines[0],
|
|
||||||
Affine3A::IDENTITY,
|
|
||||||
0.002,
|
|
||||||
0,
|
|
||||||
&app_state.input_state.hmd,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
for quad in lines.present_xr(&xr_state, &mut command_buffer) {
|
for quad in lines.present_xr(&xr_state, &mut command_buffer) {
|
||||||
layers.push((0.0, quad));
|
layers.push((0.0, quad));
|
||||||
}
|
}
|
||||||
@@ -314,6 +316,9 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app_state.hid_provider.on_new_frame();
|
app_state.hid_provider.on_new_frame();
|
||||||
|
|
||||||
|
let watch = overlays.mut_by_id(watch_id).unwrap();
|
||||||
|
watch.state.transform = watch_transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -744,14 +744,10 @@ enum LeftRight {
|
|||||||
Right,
|
Right,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn watch_fade<D>(app: &mut AppState, overlays: &mut OverlayContainer<D>)
|
pub fn watch_fade<D>(app: &mut AppState, watch: &mut OverlayData<D>)
|
||||||
where
|
where
|
||||||
D: Default,
|
D: Default,
|
||||||
{
|
{
|
||||||
let watch = overlays
|
|
||||||
.mut_by_selector(&OverlaySelector::Name(WATCH_NAME.into()))
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
if watch.state.spawn_scale < f32::EPSILON {
|
if watch.state.spawn_scale < f32::EPSILON {
|
||||||
watch.state.want_visible = false;
|
watch.state.want_visible = false;
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user