瀏覽代碼

Convert integers to type T in quaternion mat3_cast()

This fixes issues when the type T is not explicitly convertible to T, and for example only has an operator* defined that takes two Ts but not a T and an int.

All the other functions in that file already use this syntax, so the missing ones here are most likely an oversight.
Patrik Huber 9 年之前
父節點
當前提交
3b4856cf58
共有 1 個文件被更改,包括 9 次插入9 次删除
  1. 9 9
      glm/gtc/quaternion.inl

+ 9 - 9
glm/gtc/quaternion.inl

@@ -603,17 +603,17 @@ namespace detail
 		T qwy(q.w * q.y);
 		T qwz(q.w * q.z);
 
-		Result[0][0] = 1 - 2 * (qyy +  qzz);
-		Result[0][1] = 2 * (qxy + qwz);
-		Result[0][2] = 2 * (qxz - qwy);
+		Result[0][0] = T(1) - T(2) * (qyy +  qzz);
+		Result[0][1] = T(2) * (qxy + qwz);
+		Result[0][2] = T(2) * (qxz - qwy);
 
-		Result[1][0] = 2 * (qxy - qwz);
-		Result[1][1] = 1 - 2 * (qxx +  qzz);
-		Result[1][2] = 2 * (qyz + qwx);
+		Result[1][0] = T(2) * (qxy - qwz);
+		Result[1][1] = T(1) - T(2) * (qxx +  qzz);
+		Result[1][2] = T(2) * (qyz + qwx);
 
-		Result[2][0] = 2 * (qxz + qwy);
-		Result[2][1] = 2 * (qyz - qwx);
-		Result[2][2] = 1 - 2 * (qxx +  qyy);
+		Result[2][0] = T(2) * (qxz + qwy);
+		Result[2][1] = T(2) * (qyz - qwx);
+		Result[2][2] = T(1) - T(2) * (qxx +  qyy);
 		return Result;
 	}