fix keyboard scaling, fix openvr spawn
This commit is contained in:
@@ -63,7 +63,6 @@ impl LinePool {
|
|||||||
state: OverlayState {
|
state: OverlayState {
|
||||||
name: Arc::from(format!("wlx-line{}", id)),
|
name: Arc::from(format!("wlx-line{}", id)),
|
||||||
show_hide: true,
|
show_hide: true,
|
||||||
spawn_scale: 0.002,
|
|
||||||
size: (0, 0),
|
size: (0, 0),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
@@ -73,6 +72,10 @@ impl LinePool {
|
|||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
|
data: OpenVrOverlayData {
|
||||||
|
width: 0.002,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
data.data.sort_order = 69;
|
data.data.sort_order = 69;
|
||||||
|
|||||||
@@ -12,16 +12,15 @@ use crate::{
|
|||||||
state::AppState,
|
state::AppState,
|
||||||
};
|
};
|
||||||
|
|
||||||
const WIDTH: f32 = 1.0;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(super) struct OpenVrOverlayData {
|
pub(super) struct OpenVrOverlayData {
|
||||||
handle: Option<OverlayHandle>,
|
pub(super) handle: Option<OverlayHandle>,
|
||||||
last_image: Option<u64>,
|
pub(super) last_image: Option<u64>,
|
||||||
pub(super) visible: bool,
|
pub(super) visible: bool,
|
||||||
pub(super) color: Vec4,
|
pub(super) color: Vec4,
|
||||||
pub(super) curvature: f32,
|
pub(super) curvature: f32,
|
||||||
pub(super) sort_order: u32,
|
pub(super) sort_order: u32,
|
||||||
|
pub(crate) width: f32,
|
||||||
pub(super) relative_to: RelativeTo,
|
pub(super) relative_to: RelativeTo,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +48,11 @@ impl OverlayData<OpenVrOverlayData> {
|
|||||||
self.data.color = Vec4::ONE;
|
self.data.color = Vec4::ONE;
|
||||||
|
|
||||||
self.init(app);
|
self.init(app);
|
||||||
|
self.upload_transform(overlay);
|
||||||
|
|
||||||
|
if self.data.width < f32::EPSILON {
|
||||||
|
self.data.width = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
self.upload_width(overlay);
|
self.upload_width(overlay);
|
||||||
self.upload_color(overlay);
|
self.upload_color(overlay);
|
||||||
@@ -125,7 +129,7 @@ impl OverlayData<OpenVrOverlayData> {
|
|||||||
log::debug!("{}: No overlay handle", self.state.name);
|
log::debug!("{}: No overlay handle", self.state.name);
|
||||||
return;
|
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);
|
panic!("Failed to set overlay width: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,16 +98,14 @@ impl OverlayState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn reset(&mut self, app: &mut AppState) {
|
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);
|
||||||
let translation = app.input_state.hmd.transform_point3a(self.spawn_point);
|
self.transform = Affine3A::from_scale_rotation_translation(
|
||||||
self.transform = Affine3A::from_scale_rotation_translation(
|
Vec3::ONE * self.spawn_scale,
|
||||||
Vec3::ONE * self.spawn_scale,
|
Quat::IDENTITY,
|
||||||
Quat::IDENTITY,
|
translation.into(),
|
||||||
translation.into(),
|
);
|
||||||
);
|
|
||||||
|
|
||||||
self.realign(&app.input_state.hmd);
|
self.realign(&app.input_state.hmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pub fn realign(&mut self, hmd: &Affine3A) {
|
pub fn realign(&mut self, hmd: &Affine3A) {
|
||||||
let to_hmd = hmd.translation - self.transform.translation;
|
let to_hmd = hmd.translation - self.transform.translation;
|
||||||
|
|||||||
@@ -106,13 +106,10 @@ where
|
|||||||
|
|
||||||
let canvas = canvas.build();
|
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 = 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 {
|
OverlayData {
|
||||||
state: OverlayState {
|
state: OverlayState {
|
||||||
|
|||||||
Reference in New Issue
Block a user