fix keyboard scaling, fix openvr spawn

This commit is contained in:
galister
2024-01-28 20:01:17 +01:00
parent 328ef3cfde
commit 220b87659e
4 changed files with 23 additions and 21 deletions

View File

@@ -63,7 +63,6 @@ impl LinePool {
state: OverlayState {
name: Arc::from(format!("wlx-line{}", id)),
show_hide: true,
spawn_scale: 0.002,
size: (0, 0),
..Default::default()
},
@@ -73,6 +72,10 @@ impl LinePool {
}),
..Default::default()
}),
data: OpenVrOverlayData {
width: 0.002,
..Default::default()
},
..Default::default()
};
data.data.sort_order = 69;

View File

@@ -12,16 +12,15 @@ use crate::{
state::AppState,
};
const WIDTH: f32 = 1.0;
#[derive(Default)]
pub(super) struct OpenVrOverlayData {
handle: Option<OverlayHandle>,
last_image: Option<u64>,
pub(super) handle: Option<OverlayHandle>,
pub(super) last_image: Option<u64>,
pub(super) visible: bool,
pub(super) color: Vec4,
pub(super) curvature: f32,
pub(super) sort_order: u32,
pub(crate) width: f32,
pub(super) relative_to: RelativeTo,
}
@@ -49,6 +48,11 @@ impl OverlayData<OpenVrOverlayData> {
self.data.color = Vec4::ONE;
self.init(app);
self.upload_transform(overlay);
if self.data.width < f32::EPSILON {
self.data.width = 1.0;
}
self.upload_width(overlay);
self.upload_color(overlay);
@@ -125,7 +129,7 @@ impl OverlayData<OpenVrOverlayData> {
log::debug!("{}: No overlay handle", self.state.name);
return;
};
if let Err(e) = overlay.set_width(handle, WIDTH) {
if let Err(e) = overlay.set_width(handle, self.data.width) {
panic!("Failed to set overlay width: {}", e);
}
}

View File

@@ -98,7 +98,6 @@ impl OverlayState {
}
}
pub fn reset(&mut self, app: &mut AppState) {
if let RelativeTo::None = self.relative_to {
let translation = app.input_state.hmd.transform_point3a(self.spawn_point);
self.transform = Affine3A::from_scale_rotation_translation(
Vec3::ONE * self.spawn_scale,
@@ -108,7 +107,6 @@ impl OverlayState {
self.realign(&app.input_state.hmd);
}
}
pub fn realign(&mut self, hmd: &Affine3A) {
let to_hmd = hmd.translation - self.transform.translation;
let up_dir: Vec3A;

View File

@@ -106,13 +106,10 @@ where
let canvas = canvas.build();
let interaction_transform = Affine2::from_translation(vec2(0.5, 0.5))
* Affine2::from_scale(vec2(1., -size.x as f32 / size.y as f32));
let width = LAYOUT.row_size * 0.05;
let width_inv = 1.0 / width;
let aspect_ratio = size.x / size.y;
let t_w = width_inv;
let t_h = -(width_inv) * aspect_ratio;
let interaction_transform =
Affine2::from_scale_angle_translation(vec2(t_w, t_h), 0.0, vec2(0.5, 0.5));
OverlayData {
state: OverlayState {