OpenVRDispalyPlugin: fix one-frame lag in resetSensors.

resetSensors() should take place immediately, so that the getHeadPose() after the reset should be identity. (or close to it)
This commit is contained in:
Anthony J. Thibault 2016-05-19 13:56:40 -07:00
parent 654ed33dd4
commit 8381e74fb3

View file

@ -122,7 +122,19 @@ void OpenVrDisplayPlugin::customizeContext() {
void OpenVrDisplayPlugin::resetSensors() {
Lock lock(_poseMutex);
glm::mat4 m = toGlm(_trackedDevicePose[0].mDeviceToAbsoluteTracking);
glm::mat4 oldSensorResetMat = _sensorResetMat;
_sensorResetMat = glm::inverse(cancelOutRollAndPitch(m));
glm::mat4 undoRedoMat = _sensorResetMat * glm::inverse(oldSensorResetMat);
// update the device poses, by undoing the previous sensorResetMatrix then applying the new one.
for (int i = 0; i < vr::k_unMaxTrackedDeviceCount; i++) {
_trackedDevicePoseMat4[i] = undoRedoMat * _trackedDevicePoseMat4[i];
_trackedDeviceLinearVelocities[i] = transformVectorFast(undoRedoMat, _trackedDeviceLinearVelocities[i]);
_trackedDeviceAngularVelocities[i] = transformVectorFast(undoRedoMat, _trackedDeviceAngularVelocities[i]);
}
_currentRenderFrameInfo.renderPose = _trackedDevicePoseMat4[vr::k_unTrackedDeviceIndex_Hmd];
}