mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01: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) {
|
||||
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) {
|
||||
|
|
Loading…
Reference in a new issue