From a73397198c4c8d5ef0debe792ecff5d06646a038 Mon Sep 17 00:00:00 2001 From: ulfjorensen Date: Mon, 12 Dec 2011 08:44:48 +0000 Subject: [PATCH] - Bugfix #3457587: correct decomposition of matrices with negative scaling. Thanks to anonymous google account user for the fix. git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@1099 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/ColladaLoader.cpp | 3 ++- include/aiMatrix4x4.inl | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/ColladaLoader.cpp b/code/ColladaLoader.cpp index 6b4870ac8..e5f4d983a 100644 --- a/code/ColladaLoader.cpp +++ b/code/ColladaLoader.cpp @@ -1084,8 +1084,9 @@ void ColladaLoader::CreateAnimation( aiScene* pScene, const ColladaParser& pPars for( size_t a = 0; a < resultTrafos.size(); ++a) { - const aiMatrix4x4& mat = resultTrafos[a]; + aiMatrix4x4 mat = resultTrafos[a]; double time = double( mat.d4); // remember? time is stored in mat.d4 + mat.d4 = 1.0f; dstAnim->mPositionKeys[a].mTime = time; dstAnim->mRotationKeys[a].mTime = time; diff --git a/include/aiMatrix4x4.inl b/include/aiMatrix4x4.inl index fa37dd4e2..a922c4afe 100644 --- a/include/aiMatrix4x4.inl +++ b/include/aiMatrix4x4.inl @@ -217,6 +217,13 @@ inline void aiMatrix4x4::Decompose (aiVector3D& scaling, aiQuaternion& rotation, scaling.y = vRows[1].Length(); scaling.z = vRows[2].Length(); + // and the sign of the scaling + if (Determinant() < 0) { + scaling.x = -scaling.x; + scaling.y = -scaling.y; + scaling.z = -scaling.z; + } + // and remove all scaling from the matrix if(scaling.x) {