From 1a67b80ef3fe660653d15406f565ba68997200ae Mon Sep 17 00:00:00 2001 From: Kung-vr Date: Sat, 26 Oct 2019 01:12:36 +0900 Subject: [PATCH] Add a sanity check on space drag distance per frame Limits space drag to 100m per frame. This is to address a bug where universe offset openvr clamping triggering a reset might send the play back out of bounds because an active hand drag repositioned them back there (moving the user either 1000m or 40,000m in a single frame. --- src/tabcontrollers/MoveCenterTabController.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/tabcontrollers/MoveCenterTabController.cpp b/src/tabcontrollers/MoveCenterTabController.cpp index bb7d200..f1339bb 100644 --- a/src/tabcontrollers/MoveCenterTabController.cpp +++ b/src/tabcontrollers/MoveCenterTabController.cpp @@ -1323,6 +1323,11 @@ void MoveCenterTabController::reset() m_offsetY = 0.0f; m_offsetZ = 0.0f; m_rotation = 0; + m_lastControllerPosition[0] = 0.0f; + m_lastControllerPosition[1] = 0.0f; + m_lastControllerPosition[2] = 0.0f; + m_lastMoveHand = vr::TrackedControllerRole_Invalid; + m_lastRotateHand = vr::TrackedControllerRole_Invalid; applyChaperoneResetData(); emit offsetXChanged( m_offsetX ); emit offsetYChanged( m_offsetY ); @@ -2546,6 +2551,14 @@ void MoveCenterTabController::updateHandDrag( // offset is un-rotated coordinates + // prevent positional glitches from exceeding max openvr offset clamps. + // We do this by detecting a drag larger than 100m in a single frame. + if ( abs( diff[0] ) > 100.0 || abs( diff[1] ) > 100.0 + || abs( diff[2] ) > 100.0 ) + { + reset(); + } + // prevents updating if axis movement is locked if ( !m_lockXToggle ) {