From b57b77b06a7d2b56118c60f48d0b9e5719f98ef1 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Sun, 10 Mar 2024 14:08:12 +0100 Subject: [PATCH] openvr: reset offsets reloads from disk --- src/backend/openvr/mod.rs | 2 +- src/backend/openvr/playspace.rs | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/backend/openvr/mod.rs b/src/backend/openvr/mod.rs index 0785e61..9393c46 100644 --- a/src/backend/openvr/mod.rs +++ b/src/backend/openvr/mod.rs @@ -214,7 +214,7 @@ pub fn openvr_run(running: Arc) -> Result<(), BackendError> { playspace.fix_floor(&mut chaperone_mgr, &state.input_state); } SystemTask::ResetPlayspace => { - playspace.reset_offset(&mut chaperone_mgr); + playspace.reset_offset(&mut chaperone_mgr, &state.input_state); } }, } diff --git a/src/backend/openvr/playspace.rs b/src/backend/openvr/playspace.rs index ed60e79..3cab265 100644 --- a/src/backend/openvr/playspace.rs +++ b/src/backend/openvr/playspace.rs @@ -1,4 +1,4 @@ -use glam::{Affine3A, Vec3A}; +use glam::{Affine3A, Vec3, Vec3A}; use ovr_overlay::{ chaperone_setup::ChaperoneSetupManager, compositor::CompositorManager, @@ -93,14 +93,20 @@ impl PlayspaceMover { } } - pub fn reset_offset(&mut self, chaperone_mgr: &mut ChaperoneSetupManager) { + pub fn reset_offset(&mut self, chaperone_mgr: &mut ChaperoneSetupManager, input: &InputState) { if self.universe == ETrackingUniverseOrigin::TrackingUniverseStanding { - if let Some(cur) = get_working_copy(&self.universe, chaperone_mgr) { - apply_chaperone_transform(cur, chaperone_mgr); + chaperone_mgr.reload_from_disk(EChaperoneConfigFile::EChaperoneConfigFile_Live); + chaperone_mgr.commit_working_copy(EChaperoneConfigFile::EChaperoneConfigFile_Live); + } else { + let mut height = 1.7; + if let Some(mat) = get_working_copy(&self.universe, chaperone_mgr) { + height = input.hmd.translation.y - mat.translation.y; } + + let xform = Affine3A::from_translation(Vec3::Y * height); + set_working_copy(&self.universe, chaperone_mgr, &xform); + chaperone_mgr.commit_working_copy(EChaperoneConfigFile::EChaperoneConfigFile_Live); } - set_working_copy(&self.universe, chaperone_mgr, &Affine3A::IDENTITY); - chaperone_mgr.commit_working_copy(EChaperoneConfigFile::EChaperoneConfigFile_Live); if self.last.is_some() { log::info!("Space drag interrupted by manual reset");