auto-hide watch

This commit is contained in:
galister
2024-02-06 21:25:38 +01:00
parent 041dc44a58
commit c1841243ce
5 changed files with 43 additions and 2 deletions

View File

@@ -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;
}
}