Bug 1355648 - Part 1: Check VR controllers if losing tracking; r?kip
MozReview-Commit-ID: B8DaBmz1mJo
--- a/gfx/vr/gfxVROculus.cpp
+++ b/gfx/vr/gfxVROculus.cpp
@@ -1259,16 +1259,17 @@ VRSystemManagerOculus::HandleInput()
poseState.angularVelocity[0] = pose.AngularVelocity.x;
poseState.angularVelocity[1] = pose.AngularVelocity.y;
poseState.angularVelocity[2] = pose.AngularVelocity.z;
poseState.flags |= GamepadCapabilityFlags::Cap_AngularAcceleration;
poseState.angularAcceleration[0] = pose.AngularAcceleration.x;
poseState.angularAcceleration[1] = pose.AngularAcceleration.y;
poseState.angularAcceleration[2] = pose.AngularAcceleration.z;
+ poseState.isOrientationValid = true;
}
if (state.HandStatusFlags[handIdx] & ovrStatus_PositionTracked) {
poseState.flags |= GamepadCapabilityFlags::Cap_Position;
poseState.position[0] = pose.ThePose.Position.x;
poseState.position[1] = pose.ThePose.Position.y;
poseState.position[2] = pose.ThePose.Position.z;
poseState.linearVelocity[0] = pose.LinearVelocity.x;
poseState.linearVelocity[1] = pose.LinearVelocity.y;
@@ -1276,16 +1277,17 @@ VRSystemManagerOculus::HandleInput()
poseState.flags |= GamepadCapabilityFlags::Cap_LinearAcceleration;
poseState.linearAcceleration[0] = pose.LinearAcceleration.x;
poseState.linearAcceleration[1] = pose.LinearAcceleration.y;
poseState.linearAcceleration[2] = pose.LinearAcceleration.z;
float eyeHeight = ovr_GetFloat(mSession, OVR_KEY_EYE_HEIGHT, OVR_DEFAULT_EYE_HEIGHT);
poseState.position[1] -= eyeHeight;
+ poseState.isPositionValid = true;
}
HandlePoseTracking(i, poseState, controller);
}
}
void
VRSystemManagerOculus::HandleButtonPress(uint32_t aControllerIdx,
uint32_t aButton,
--- a/gfx/vr/gfxVROpenVR.cpp
+++ b/gfx/vr/gfxVROpenVR.cpp
@@ -709,51 +709,56 @@ VRSystemManagerOpenVR::HandleInput()
}
MOZ_ASSERT(buttonIdx ==
controller->GetControllerInfo().GetNumButtons());
controller->SetButtonPressed(state.ulButtonPressed);
controller->SetButtonTouched(state.ulButtonTouched);
// Start to process pose
const ::vr::TrackedDevicePose_t& pose = poses[trackedIndex];
+ GamepadPoseState poseState;
- if (pose.bDeviceIsConnected && pose.bPoseIsValid &&
- pose.eTrackingResult == ::vr::TrackingResult_Running_OK) {
+ if (pose.bDeviceIsConnected) {
+ poseState.flags |= (GamepadCapabilityFlags::Cap_Orientation |
+ GamepadCapabilityFlags::Cap_Position);
+ }
+
+ if (pose.bPoseIsValid &&
+ pose.eTrackingResult == ::vr::TrackingResult_Running_OK) {
gfx::Matrix4x4 m;
// NOTE! mDeviceToAbsoluteTracking is a 3x4 matrix, not 4x4. But
// because of its arrangement, we can copy the 12 elements in and
// then transpose them to the right place. We do this so we can
// pull out a Quaternion.
memcpy(&m.components, &pose.mDeviceToAbsoluteTracking, sizeof(float) * 12);
m.Transpose();
gfx::Quaternion rot;
rot.SetFromRotationMatrix(m);
rot.Invert();
- GamepadPoseState poseState;
- poseState.flags |= GamepadCapabilityFlags::Cap_Orientation;
poseState.orientation[0] = rot.x;
poseState.orientation[1] = rot.y;
poseState.orientation[2] = rot.z;
poseState.orientation[3] = rot.w;
poseState.angularVelocity[0] = pose.vAngularVelocity.v[0];
poseState.angularVelocity[1] = pose.vAngularVelocity.v[1];
poseState.angularVelocity[2] = pose.vAngularVelocity.v[2];
+ poseState.isOrientationValid = true;
- poseState.flags |= GamepadCapabilityFlags::Cap_Position;
poseState.position[0] = m._41;
poseState.position[1] = m._42;
poseState.position[2] = m._43;
poseState.linearVelocity[0] = pose.vVelocity.v[0];
poseState.linearVelocity[1] = pose.vVelocity.v[1];
poseState.linearVelocity[2] = pose.vVelocity.v[2];
- HandlePoseTracking(i, poseState, controller);
+ poseState.isPositionValid = true;
}
+ HandlePoseTracking(i, poseState, controller);
}
}
}
void
VRSystemManagerOpenVR::HandleButtonPress(uint32_t aControllerIdx,
uint32_t aButton,
uint64_t aButtonMask,