auto-hide watch
This commit is contained in:
@@ -24,6 +24,7 @@ use crate::{
|
||||
osc::OscSender,
|
||||
},
|
||||
graphics::WlxGraphics,
|
||||
overlays::watch::watch_fade,
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
@@ -179,6 +180,7 @@ pub fn openvr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
.iter_mut()
|
||||
.for_each(|o| o.state.auto_movement(&mut state));
|
||||
|
||||
watch_fade(&mut state, &mut overlays);
|
||||
space_mover.update(&mut chaperone_mgr, &mut overlays, &state);
|
||||
|
||||
let lengths_haptics = interact(&mut overlays, &mut state);
|
||||
|
||||
@@ -18,6 +18,7 @@ use crate::{
|
||||
osc::OscSender,
|
||||
},
|
||||
graphics::WlxGraphics,
|
||||
overlays::watch::watch_fade,
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
@@ -210,6 +211,8 @@ pub fn openxr_run(running: Arc<AtomicBool>) -> Result<(), BackendError> {
|
||||
}
|
||||
}
|
||||
|
||||
watch_fade(&mut app_state, &mut overlays);
|
||||
|
||||
overlays
|
||||
.iter_mut()
|
||||
.for_each(|o| o.after_input(&mut app_state));
|
||||
|
||||
@@ -27,6 +27,10 @@ fn def_one() -> f32 {
|
||||
1.0
|
||||
}
|
||||
|
||||
fn def_half() -> f32 {
|
||||
0.5
|
||||
}
|
||||
|
||||
fn def_osc_port() -> u16 {
|
||||
9000
|
||||
}
|
||||
@@ -48,6 +52,9 @@ pub struct GeneralConfig {
|
||||
#[serde(default = "def_one")]
|
||||
pub watch_scale: f32,
|
||||
|
||||
#[serde(default = "def_half")]
|
||||
pub watch_view_angle: f32,
|
||||
|
||||
#[serde(default = "def_pw_tokens")]
|
||||
pub pw_tokens: Vec<(String, String)>,
|
||||
|
||||
|
||||
@@ -7,12 +7,12 @@ use std::{
|
||||
|
||||
use chrono::Local;
|
||||
use chrono_tz::Tz;
|
||||
use glam::{vec2, Affine2, Vec3};
|
||||
use glam::{vec2, Affine2, Vec3, Vec3A};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
backend::{
|
||||
common::{OverlaySelector, TaskType},
|
||||
common::{OverlayContainer, OverlaySelector, TaskType},
|
||||
input::PointerMode,
|
||||
overlay::{OverlayData, OverlayState, RelativeTo},
|
||||
},
|
||||
@@ -595,3 +595,26 @@ enum LeftRight {
|
||||
Left,
|
||||
Right,
|
||||
}
|
||||
|
||||
pub fn watch_fade<D>(app: &mut AppState, overlays: &mut OverlayContainer<D>)
|
||||
where
|
||||
D: Default,
|
||||
{
|
||||
let watch = overlays
|
||||
.mut_by_selector(&OverlaySelector::Name(WATCH_NAME.into()))
|
||||
.unwrap();
|
||||
|
||||
let to_hmd = (watch.state.transform.translation - app.input_state.hmd.translation).normalize();
|
||||
let watch_normal = watch
|
||||
.state
|
||||
.transform
|
||||
.transform_vector3a(Vec3A::NEG_Z)
|
||||
.normalize();
|
||||
let dot = to_hmd.dot(watch_normal);
|
||||
|
||||
if dot < app.session.config.watch_view_angle {
|
||||
watch.state.want_visible = false;
|
||||
} else {
|
||||
watch.state.want_visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,18 @@
|
||||
|
||||
# render resolution of the watch
|
||||
|
||||
watch_view_angle: 0.5 # 0 = 90 deg, 1 = 0 deg
|
||||
|
||||
# TODO
|
||||
watch_hand: Left
|
||||
|
||||
# TODO
|
||||
watch_offset: []
|
||||
|
||||
# TODO
|
||||
watch_rotation: []
|
||||
|
||||
# TODO
|
||||
watch_size: [400, 200]
|
||||
|
||||
watch_elements:
|
||||
|
||||
Reference in New Issue
Block a user