mirror of https://github.com/wayvr-org/wayvr.git
openvr: copy reset_offset logic from openxr
This commit is contained in:
parent
7c16748f88
commit
9e43b9b3ad
|
|
@ -23,14 +23,16 @@ pub(super) struct PlayspaceMover {
|
||||||
universe: ETrackingUniverseOrigin,
|
universe: ETrackingUniverseOrigin,
|
||||||
drag: Option<MoverData<Vec3A>>,
|
drag: Option<MoverData<Vec3A>>,
|
||||||
rotate: Option<MoverData<Quat>>,
|
rotate: Option<MoverData<Quat>>,
|
||||||
|
floor_y: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PlayspaceMover {
|
impl PlayspaceMover {
|
||||||
pub const fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
universe: ETrackingUniverseOrigin::TrackingUniverseRawAndUncalibrated,
|
universe: ETrackingUniverseOrigin::TrackingUniverseRawAndUncalibrated,
|
||||||
drag: None,
|
drag: None,
|
||||||
rotate: None,
|
rotate: None,
|
||||||
|
floor_y: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,13 +179,10 @@ impl PlayspaceMover {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset_offset(&mut self, chaperone_mgr: &mut ChaperoneSetupManager, input: &InputState) {
|
pub fn reset_offset(&mut self, chaperone_mgr: &mut ChaperoneSetupManager, input: &InputState) {
|
||||||
let mut height = 1.6;
|
let height = match self.floor_y {
|
||||||
if let Some(mat) = get_working_copy(&self.universe, chaperone_mgr) {
|
Some(y) => y,
|
||||||
height = input.hmd.translation.y - mat.translation.y;
|
None => input.hmd.translation.y - 1.7,
|
||||||
if self.universe == ETrackingUniverseOrigin::TrackingUniverseStanding {
|
};
|
||||||
apply_chaperone_transform(mat, chaperone_mgr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let xform = if self.universe == ETrackingUniverseOrigin::TrackingUniverseSeated {
|
let xform = if self.universe == ETrackingUniverseOrigin::TrackingUniverseSeated {
|
||||||
Affine3A::from_translation(Vec3::NEG_Y * height)
|
Affine3A::from_translation(Vec3::NEG_Y * height)
|
||||||
|
|
@ -213,6 +212,7 @@ impl PlayspaceMover {
|
||||||
};
|
};
|
||||||
let offset = y1.min(y2) - 0.03;
|
let offset = y1.min(y2) - 0.03;
|
||||||
mat.translation.y += offset;
|
mat.translation.y += offset;
|
||||||
|
self.floor_y = Some(mat.translation.y);
|
||||||
|
|
||||||
set_working_copy(&self.universe, chaperone_mgr, &mat);
|
set_working_copy(&self.universe, chaperone_mgr, &mat);
|
||||||
chaperone_mgr.commit_working_copy(EChaperoneConfigFile::EChaperoneConfigFile_Live);
|
chaperone_mgr.commit_working_copy(EChaperoneConfigFile::EChaperoneConfigFile_Live);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue