Bug 1426028 - Head rotation was being applied twice in gfxVRGVR r=kip draft
authorRandall Barker <rbarker@mozilla.com>
Mon, 18 Dec 2017 12:43:45 -0800
changeset 712898 8c561020a91898d31d36beddacd1979e9010a947
parent 712897 7a22c2efc68dbd582ae9b1d22bc6b29d75c5bd86
child 712899 b19e52b020bbdd15bf757e59b0b39e3c6ce557f9
push id93471
push userbmo:rbarker@mozilla.com
push dateTue, 19 Dec 2017 02:02:26 +0000
reviewerskip
bugs1426028
milestone59.0a1
Bug 1426028 - Head rotation was being applied twice in gfxVRGVR r=kip MozReview-Commit-ID: IzcRfzE7qxV
gfx/vr/gfxVRGVR.cpp
gfx/vr/gfxVRGVR.h
--- a/gfx/vr/gfxVRGVR.cpp
+++ b/gfx/vr/gfxVRGVR.cpp
@@ -402,17 +402,17 @@ VRDisplayGVR::GetSensorState()
   result.flags |= VRDisplayCapabilityFlags::Cap_Position;
   result.position[0] = m._14;
   result.position[1] = m._24;
   result.position[2] = m._34;
   result.linearVelocity[0] = 0.0f;
   result.linearVelocity[1] = 0.0f;
   result.linearVelocity[2] = 0.0f;
 
-  UpdateHeadToEye(context, &rot);
+  UpdateHeadToEye(context);
   result.CalcViewMatrices(mHeadToEyes);
 
   return result;
 }
 
 void
 VRDisplayGVR::SetPaused(const bool aPaused)
 {
@@ -461,32 +461,28 @@ VRDisplayGVR::SetPresentingContext(void*
     // generation if we are presenting so that the DOM knows to end the current presentation.
     if (mIsPresenting) {
       mDisplayInfo.mPresentingGeneration++;
     }
   }
 }
 
 void
-VRDisplayGVR::UpdateHeadToEye(gvr_context* aContext, gfx::Quaternion* aRot)
+VRDisplayGVR::UpdateHeadToEye(gvr_context* aContext)
 {
   if (!aContext) {
     return;
   }
 
   for (uint32_t eyeIndex = 0; eyeIndex < 2; eyeIndex++) {
     gvr_mat4f eye = GVR_CHECK(gvr_get_eye_from_head_matrix(aContext, eyeIndex));
     mDisplayInfo.mEyeTranslation[eyeIndex].x = -eye.m[0][3];
     mDisplayInfo.mEyeTranslation[eyeIndex].y = -eye.m[1][3];
     mDisplayInfo.mEyeTranslation[eyeIndex].z = -eye.m[2][3];
-    if (aRot) {
-      mHeadToEyes[eyeIndex].SetRotationFromQuaternion(*aRot);
-    } else {
-      mHeadToEyes[eyeIndex] = gfx::Matrix4x4();
-    }
+    mHeadToEyes[eyeIndex] = gfx::Matrix4x4();
     mHeadToEyes[eyeIndex].PreTranslate(eye.m[0][3], eye.m[1][3], eye.m[2][3]);
   }
 }
 
 void
 VRDisplayGVR::UpdateViewport()
 {
   gvr_context* context = (mPresentingContext ? mPresentingContext : GetNonPresentingContext());
--- a/gfx/vr/gfxVRGVR.h
+++ b/gfx/vr/gfxVRGVR.h
@@ -68,17 +68,17 @@ public:
   void SetPaused(const bool aPaused);
   void SetPresentingContext(void* aGVRPresentingContext);
   void EnableControllers(const bool aEnable, VRSystemManager* aManager);
   void UpdateControllers(VRSystemManager* aManager);
   void GetControllers(nsTArray<RefPtr<VRControllerHost> >& aControllerResult);
 
 protected:
   virtual ~VRDisplayGVR();
-  void UpdateHeadToEye(gvr_context* aContext, gfx::Quaternion* aRot = nullptr);
+  void UpdateHeadToEye(gvr_context* aContext);
   void UpdateViewport();
   void RecreateSwapChain();
 
   bool mIsPresenting;
   bool mControllerAdded;
 
   gfx::Matrix4x4 mHeadToEyes[2];
   gvr_context* mPresentingContext;