diff --git a/Cargo.lock b/Cargo.lock index b623117..db20798 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2198,7 +2198,7 @@ dependencies = [ [[package]] name = "ovr_overlay" version = "0.0.0" -source = "git+https://github.com/galister/ovr_overlay_oyasumi#7e1c8c545dd4d7c87d0a64cc441cba498082d810" +source = "git+https://github.com/galister/ovr_overlay_oyasumi#9d8a3f4017024e79b6ec7fa518b97df401bf259c" dependencies = [ "byteorder", "derive_more", @@ -2213,7 +2213,7 @@ dependencies = [ [[package]] name = "ovr_overlay_sys" version = "0.0.0" -source = "git+https://github.com/galister/ovr_overlay_oyasumi#7e1c8c545dd4d7c87d0a64cc441cba498082d810" +source = "git+https://github.com/galister/ovr_overlay_oyasumi#9d8a3f4017024e79b6ec7fa518b97df401bf259c" dependencies = [ "autocxx", "autocxx-build", @@ -3722,7 +3722,7 @@ dependencies = [ [[package]] name = "wlx-overlay-s" -version = "0.2.5" +version = "0.2.6" dependencies = [ "anyhow", "ash", diff --git a/Cargo.toml b/Cargo.toml index 1c303cc..748ef34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ debug = true [package] name = "wlx-overlay-s" -version = "0.2.5" +version = "0.2.6" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/backend/openvr/playspace.rs b/src/backend/openvr/playspace.rs index e1383ba..9ee5c36 100644 --- a/src/backend/openvr/playspace.rs +++ b/src/backend/openvr/playspace.rs @@ -2,7 +2,7 @@ use glam::{Affine3A, Vec3A}; use ovr_overlay::{ chaperone_setup::ChaperoneSetupManager, compositor::CompositorManager, - sys::{EChaperoneConfigFile, ETrackingUniverseOrigin, HmdMatrix34_t}, + sys::{EChaperoneConfigFile, ETrackingUniverseOrigin, HmdMatrix34_t, HmdVector3_t}, }; use crate::{ @@ -56,12 +56,16 @@ impl PlayspaceMover { return; } + let overlay_offset = data.pose.inverse().transform_vector3a(relative_pos); + overlays.iter_mut().for_each(|overlay| { if overlay.state.grabbable { overlay.state.dirty = true; - overlay.state.transform.translation -= relative_pos; + overlay.state.transform.translation -= overlay_offset; } }); + chaperone_mgr.revert_working_copy(); + apply_chaperone_offset(overlay_offset, chaperone_mgr); data.pose.translation += relative_pos; data.hand_pos = new_hand; @@ -171,3 +175,17 @@ fn set_working_copy( _ => chaperone_mgr.set_working_seated_zero_pose_to_raw_tracking_pose(&mat), }; } + +fn apply_chaperone_offset(offset: Vec3A, chaperone_mgr: &mut ChaperoneSetupManager) { + let mut quads = chaperone_mgr.get_working_collision_bounds_info(); + quads.iter_mut().for_each(|quad| { + quad.vCorners.iter_mut().for_each(|corner| { + corner.v[0] += offset.x; + if corner.v[1] != 0.0 { + corner.v[1] += offset.y; + } + corner.v[2] += offset.z; + }); + }); + chaperone_mgr.set_working_collision_bounds_info(&mut quads); +}