mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:57:00 +02:00
Fix for mirrored transforms in FBX models
extractScale will now return negative scale for left-handed matrices.
This commit is contained in:
parent
744da64c50
commit
b56cf58e33
1 changed files with 8 additions and 1 deletions
|
@ -285,7 +285,14 @@ glm::quat glmExtractRotation(const glm::mat4& matrix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 extractScale(const glm::mat4& matrix) {
|
glm::vec3 extractScale(const glm::mat4& matrix) {
|
||||||
return glm::vec3(glm::length(matrix[0]), glm::length(matrix[1]), glm::length(matrix[2]));
|
glm::mat3 m(matrix);
|
||||||
|
float det = glm::determinant(m);
|
||||||
|
if (det < 0) {
|
||||||
|
// left handed matrix, flip sign to compensate.
|
||||||
|
return glm::vec3(-glm::length(m[0]), glm::length(m[1]), glm::length(m[2]));
|
||||||
|
} else {
|
||||||
|
return glm::vec3(glm::length(m[0]), glm::length(m[1]), glm::length(m[2]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float extractUniformScale(const glm::mat4& matrix) {
|
float extractUniformScale(const glm::mat4& matrix) {
|
||||||
|
|
Loading…
Reference in a new issue