From 6ab1db9a7663e7bd2db4c4f7f41afd738292b5e3 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Thu, 15 Jan 2026 14:32:21 +0900 Subject: [PATCH] fix openvr lines --- wayvr/src/backend/openvr/lines.rs | 16 +++++++++++----- wayvr/src/backend/openvr/mod.rs | 4 +++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/wayvr/src/backend/openvr/lines.rs b/wayvr/src/backend/openvr/lines.rs index 1d38baf5..0a5a3979 100644 --- a/wayvr/src/backend/openvr/lines.rs +++ b/wayvr/src/backend/openvr/lines.rs @@ -123,7 +123,8 @@ impl LinePool { let center = (start + end) * 0.5; let dir_norm = dir / len; - let xform = Affine3A::from_rotation_translation( + let xform = Affine3A::from_scale_rotation_translation( + Vec3::new(1., len / 0.002, 1.), Quat::from_rotation_arc(Vec3::Z, dir_norm.into()), center.into(), ); @@ -133,11 +134,10 @@ impl LinePool { let to_hmd = hmd.translation - center; let sides = [Vec3A::Z, Vec3A::X, Vec3A::NEG_Z, Vec3A::NEG_X]; - #[allow(clippy::neg_multiply)] let rotations = [ Affine3A::IDENTITY, Affine3A::from_axis_angle(Vec3::Y, PI * 0.5), - Affine3A::from_axis_angle(Vec3::Y, PI * -1.0), + Affine3A::from_axis_angle(Vec3::Y, PI * 1.0), Affine3A::from_axis_angle(Vec3::Y, PI * 1.5), ]; @@ -151,7 +151,6 @@ impl LinePool { transform *= rotations[closest.0]; - debug_assert!(color < self.colors.len()); self.draw_transform(id, transform, self.colors[color]); } @@ -175,7 +174,7 @@ impl LinePool { for data in self.lines.values_mut() { data.after_input(overlay, app)?; let state = data.config.active_state.as_mut().unwrap(); - if state.alpha > 0.01 { + if state.alpha > 0.05 { if data.config.dirty { data.upload_texture(overlay, &app.gfx); data.config.dirty = false; @@ -193,6 +192,13 @@ impl LinePool { data.config.dirty = true; } } + + pub fn reset(&mut self) { + for data in self.lines.values_mut() { + let state = data.config.active_state.as_mut().unwrap(); + state.alpha = 0.0; + } + } } struct LineBackend { diff --git a/wayvr/src/backend/openvr/mod.rs b/wayvr/src/backend/openvr/mod.rs index 695d1d20..00ffe088 100644 --- a/wayvr/src/backend/openvr/mod.rs +++ b/wayvr/src/backend/openvr/mod.rs @@ -340,6 +340,8 @@ pub fn openvr_run(show_by_default: bool, headless: bool) -> Result<(), BackendEr .values_mut() .for_each(|o| o.after_render(universe.clone(), &mut overlay_mgr, &app.gfx)); + lines.reset(); + // chaperone } // main_loop @@ -353,7 +355,7 @@ pub fn openvr_run(show_by_default: bool, headless: bool) -> Result<(), BackendEr } log::warn!("OpenVR shutdown"); - // context.shutdown() called by Drop + unsafe { context.shutdown() }; Ok(()) }