openvr: correct size for portrait overlays

This commit is contained in:
galister
2024-03-19 18:16:23 +01:00
parent 3907e089de
commit 0d41bf1a3e
2 changed files with 11 additions and 0 deletions

View File

@@ -75,6 +75,7 @@ impl LinePool {
}),
data: OpenVrOverlayData {
width: 0.002,
override_width: true,
..Default::default()
},
..Default::default()

View File

@@ -24,6 +24,7 @@ pub(super) struct OpenVrOverlayData {
pub(super) curvature: f32,
pub(super) sort_order: u32,
pub(crate) width: f32,
pub(super) override_width: bool,
pub(super) relative_to: RelativeTo,
}
@@ -233,6 +234,15 @@ impl OverlayData<OpenVrOverlayData> {
}
let dimensions = image.extent();
if !self.data.override_width {
let new_width = ((dimensions[0] as f32) / (dimensions[1] as f32)).min(1.0);
if (new_width - self.data.width).abs() > f32::EPSILON {
log::info!("{}: New width {}", self.state.name, new_width);
self.data.width = new_width;
self.upload_width(overlay);
}
}
let format = image.format();
let mut texture = VRVulkanTextureData_t {