Fixed glm::decompose #448
This commit is contained in:
@@ -147,47 +147,34 @@ namespace detail
|
|||||||
// ret.rotateZ = 0;
|
// ret.rotateZ = 0;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
T s, t, x, y, z, w;
|
int i, j, k = 0;
|
||||||
|
float root, trace = Row[0].x + Row[1].y + Row[2].z;
|
||||||
t = Row[0][0] + Row[1][1] + Row[2][2] + static_cast<T>(1);
|
if(trace > static_cast<T>(0))
|
||||||
|
|
||||||
if(t > static_cast<T>(1e-4))
|
|
||||||
{
|
{
|
||||||
s = static_cast<T>(0.5) / sqrt(t);
|
root = sqrt(trace + static_cast<T>(1.0));
|
||||||
w = static_cast<T>(0.25) / s;
|
Orientation.w = static_cast<T>(0.5) * root;
|
||||||
x = (Row[2][1] - Row[1][2]) * s;
|
root = static_cast<T>(0.5) / root;
|
||||||
y = (Row[0][2] - Row[2][0]) * s;
|
Orientation.x = root * (Row[1].z - Row[2].y);
|
||||||
z = (Row[1][0] - Row[0][1]) * s;
|
Orientation.y = root * (Row[2].x - Row[0].z);
|
||||||
}
|
Orientation.z = root * (Row[0].y - Row[1].x);
|
||||||
else if(Row[0][0] > Row[1][1] && Row[0][0] > Row[2][2])
|
} // End if > 0
|
||||||
{
|
|
||||||
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 (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 = static_cast<T>(0.25) * s;
|
|
||||||
z = (Row[1][2] + Row[2][1]) / s;
|
|
||||||
w = (Row[0][2] - Row[2][0]) / s;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s = sqrt(static_cast<T>(1) + Row[2][2] - Row[0][0] - Row[1][1]) * static_cast<T>(2); // S=4*qz
|
static int Next[3] = {1, 2, 0};
|
||||||
x = (Row[0][2] + Row[2][0]) / s;
|
i = 0;
|
||||||
y = (Row[1][2] + Row[2][1]) / s;
|
if(Row[1].y > Row[0].x) i = 1;
|
||||||
z = static_cast<T>(0.25) * s;
|
if(Row[2].z > Row[i][i]) i = 2;
|
||||||
w = (Row[1][0] - Row[0][1]) / s;
|
j = Next[i];
|
||||||
}
|
k = Next[j];
|
||||||
|
|
||||||
Orientation.x = x;
|
root = sqrt(Row[i][i] - Row[j][j] - Row[k][k] + static_cast<T>(1.0));
|
||||||
Orientation.y = y;
|
|
||||||
Orientation.z = z;
|
Orientation[i] = static_cast<T>(0.5) * root;
|
||||||
Orientation.w = w;
|
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.w = root * (Row[j][k] - Row[k][j]);
|
||||||
|
} // End if <= 0
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ glm::mat4 camera(float Translate, glm::vec2 const & Rotate)
|
|||||||
|
|
||||||
#### Fixes:
|
#### Fixes:
|
||||||
- Removed doxygen references to GTC_half_float which was removed in 0.9.4
|
- Removed doxygen references to GTC_half_float which was removed in 0.9.4
|
||||||
|
- Fixed glm::decompose #448
|
||||||
|
|
||||||
#### Deprecation:
|
#### Deprecation:
|
||||||
- Removed GLM_GTX_simd_vec4 extension
|
- Removed GLM_GTX_simd_vec4 extension
|
||||||
|
|||||||
Reference in New Issue
Block a user