mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 19:34:36 +00:00
Fixed decompose warnings #373
This commit is contained in:
parent
37d4ca9c4c
commit
1e502c0919
@ -81,15 +81,15 @@ namespace glm
|
||||
tmat4x4<T, P> PerspectiveMatrix(LocalMatrix);
|
||||
|
||||
for(length_t i = 0; i < 3; i++)
|
||||
PerspectiveMatrix[i][3] = 0;
|
||||
PerspectiveMatrix[3][3] = 1;
|
||||
PerspectiveMatrix[i][3] = static_cast<T>(0);
|
||||
PerspectiveMatrix[3][3] = static_cast<T>(1);
|
||||
|
||||
/// TODO: Fixme!
|
||||
if(determinant(PerspectiveMatrix) == static_cast<T>(0))
|
||||
return false;
|
||||
|
||||
// First, isolate perspective. This is the messiest.
|
||||
if(LocalMatrix[0][3] != 0 || LocalMatrix[1][3] != 0 || LocalMatrix[2][3] != 0)
|
||||
if(LocalMatrix[0][3] != static_cast<T>(0) || LocalMatrix[1][3] != static_cast<T>(0) || LocalMatrix[2][3] != static_cast<T>(0))
|
||||
{
|
||||
// rightHandSide is the right hand side of the equation.
|
||||
tvec4<T, P> RightHandSide;
|
||||
@ -108,8 +108,8 @@ namespace glm
|
||||
// v4MulPointByMatrix(rightHandSide, transposedInversePerspectiveMatrix, perspectivePoint);
|
||||
|
||||
// Clear the perspective partition
|
||||
LocalMatrix[0][3] = LocalMatrix[1][3] = LocalMatrix[2][3] = 0;
|
||||
LocalMatrix[3][3] = 1;
|
||||
LocalMatrix[0][3] = LocalMatrix[1][3] = LocalMatrix[2][3] = static_cast<T>(0);
|
||||
LocalMatrix[3][3] = static_cast<T>(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -186,38 +186,38 @@ namespace glm
|
||||
|
||||
T s, t, x, y, z, w;
|
||||
|
||||
t = Row[0][0] + Row[1][1] + Row[2][2] + 1.0;
|
||||
t = Row[0][0] + Row[1][1] + Row[2][2] + static_cast<T>(1);
|
||||
|
||||
if(t > 1e-4)
|
||||
if(t > static_cast<T>(1e-4))
|
||||
{
|
||||
s = 0.5 / sqrt(t);
|
||||
w = 0.25 / s;
|
||||
s = static_cast<T>(0.5) / sqrt(t);
|
||||
w = static_cast<T>(0.25) / s;
|
||||
x = (Row[2][1] - Row[1][2]) * s;
|
||||
y = (Row[0][2] - Row[2][0]) * s;
|
||||
z = (Row[1][0] - Row[0][1]) * s;
|
||||
}
|
||||
else if(Row[0][0] > Row[1][1] && Row[0][0] > Row[2][2])
|
||||
{
|
||||
s = sqrt (1.0 + Row[0][0] - Row[1][1] - Row[2][2]) * 2.0; // S=4*qx
|
||||
x = 0.25 * s;
|
||||
s = sqrt (static_cast<T>(1) + Row[0][0] - Row[1][1] - Row[2][2]) * static_cast<T>(2); // S=4*qx
|
||||
x = static_cast<T>(0.25) * s;
|
||||
y = (Row[0][1] + Row[1][0]) / s;
|
||||
z = (Row[0][2] + Row[2][0]) / s;
|
||||
w = (Row[2][1] - Row[1][2]) / s;
|
||||
}
|
||||
else if(Row[1][1] > Row[2][2])
|
||||
{
|
||||
s = sqrt (1.0 + Row[1][1] - Row[0][0] - Row[2][2]) * 2.0; // S=4*qy
|
||||
s = sqrt (static_cast<T>(1) + Row[1][1] - Row[0][0] - Row[2][2]) * static_cast<T>(2); // S=4*qy
|
||||
x = (Row[0][1] + Row[1][0]) / s;
|
||||
y = 0.25 * s;
|
||||
y = static_cast<T>(0.25) * s;
|
||||
z = (Row[1][2] + Row[2][1]) / s;
|
||||
w = (Row[0][2] - Row[2][0]) / s;
|
||||
}
|
||||
else
|
||||
{
|
||||
s = sqrt(1.0 + Row[2][2] - Row[0][0] - Row[1][1]) * 2.0; // S=4*qz
|
||||
s = sqrt(static_cast<T>(1) + Row[2][2] - Row[0][0] - Row[1][1]) * static_cast<T>(2); // S=4*qz
|
||||
x = (Row[0][2] + Row[2][0]) / s;
|
||||
y = (Row[1][2] + Row[2][1]) / s;
|
||||
z = 0.25 * s;
|
||||
z = static_cast<T>(0.25) * s;
|
||||
w = (Row[1][0] - Row[0][1]) / s;
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
|
||||
- Fixed Intel compiler build error on Linux #354
|
||||
- Fixed use of libstdc++ with Clang #351
|
||||
- Fixed quaternion pow #346
|
||||
- Fixed decompose warnings #373
|
||||
|
||||
##### Deprecation:
|
||||
- Removed integer specification for 'mod' in GTC_integer #308
|
||||
|
@ -35,5 +35,15 @@ int main()
|
||||
{
|
||||
int Error(0);
|
||||
|
||||
glm::mat4 Matrix(1);
|
||||
|
||||
glm::vec3 Scale;
|
||||
glm::quat Orientation;
|
||||
glm::vec3 Translation;
|
||||
glm::vec3 Skew(1);
|
||||
glm::vec4 Perspective(1);
|
||||
|
||||
glm::decompose(Matrix, Scale, Orientation, Translation, Skew, Perspective);
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user