feat: persist layout between sessions

This commit is contained in:
galister
2024-04-25 08:53:54 +09:00
parent 5afb5ed4ab
commit c70833b86a
9 changed files with 65 additions and 44 deletions

View File

@@ -1,6 +1,6 @@
use std::{f32::consts::PI, ops::Add, sync::Arc, time::Instant};
use glam::{vec3a, Quat, Vec3A};
use glam::{vec3a, Quat};
use idmap_derive::IntegerId;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
@@ -127,9 +127,8 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<(OverlayState, Box<dyn
DisplayMethod::Hide => return None,
DisplayMethod::Center => (vec3a(0., -0.2, -0.5), Quat::IDENTITY, RelativeTo::Head),
DisplayMethod::Watch => {
let mut watch_pos =
Vec3A::from_slice(&app.session.config.watch_pos) + vec3a(-0.005, -0.05, 0.02);
let mut watch_rot = Quat::from_slice(&app.session.config.watch_rot);
let mut watch_pos = app.session.config.watch_pos + vec3a(-0.005, -0.05, 0.02);
let mut watch_rot = app.session.config.watch_rot;
let relative_to = match app.session.config.watch_hand {
LeftRight::Left => RelativeTo::Hand(0),
LeftRight::Right => {

View File

@@ -1,4 +1,4 @@
use glam::{Quat, Vec3A};
use glam::Vec3A;
use crate::{
backend::overlay::{ui_transform, OverlayData, OverlayState, RelativeTo},
@@ -26,8 +26,8 @@ where
want_visible: true,
interactable: true,
spawn_scale: config.width,
spawn_point: Vec3A::from_slice(&state.session.config.watch_pos),
spawn_rotation: Quat::from_slice(&state.session.config.watch_rot),
spawn_point: state.session.config.watch_pos,
spawn_rotation: state.session.config.watch_rot,
interaction_transform: ui_transform(&config.size),
relative_to,
..Default::default()