Browse Source

Merge pull request #1076 from stephomi/decompose_wxyz

Fix matrix decompose (wxyz quaternion) #1076
Christophe 4 years ago
parent
commit
84f2045a79
1 changed files with 9 additions and 3 deletions
  1. 9 3
      glm/gtx/matrix_decompose.inl

+ 9 - 3
glm/gtx/matrix_decompose.inl

@@ -172,12 +172,18 @@ namespace detail
 			j = Next[i];
 			k = Next[j];
 
+#           ifdef GLM_FORCE_QUAT_DATA_XYZW
+                int off = 0;
+#           else
+                int off = 1;
+#           endif
+
 			root = sqrt(Row[i][i] - Row[j][j] - Row[k][k] + static_cast<T>(1.0));
 
-			Orientation[i] = static_cast<T>(0.5) * root;
+			Orientation[i + off] = static_cast<T>(0.5) * root;
 			root = static_cast<T>(0.5) / root;
-			Orientation[j] = root * (Row[i][j] + Row[j][i]);
-			Orientation[k] = root * (Row[i][k] + Row[k][i]);
+			Orientation[j + off] = root * (Row[i][j] + Row[j][i]);
+			Orientation[k + off] = root * (Row[i][k] + Row[k][i]);
 			Orientation.w = root * (Row[j][k] - Row[k][j]);
 		} // End if <= 0