MD5: Fix quaternion conversions

Some of the quaternions loaded from MD5 files were not converted
to follow Assimp conventions.

https://github.com/assimp/assimp/issues/495
pull/640/head
Jaakko Keränen 2015-08-18 11:36:32 +03:00
parent 4afddf316f
commit d74a1149b7
2 changed files with 3 additions and 6 deletions

View File

@ -285,9 +285,6 @@ void MD5Importer::AttachChilds_Mesh(int iParentID,aiNode* piParent, BoneList& bo
aiQuaternion quat;
MD5::ConvertQuaternion ( bones[i].mRotationQuat, quat );
// FIX to get to Assimp's quaternion conventions
quat.w *= -1.f;
bones[i].mTransform = aiMatrix4x4 ( quat.GetMatrix());
bones[i].mTransform.a4 = bones[i].mPositionXYZ.x;
bones[i].mTransform.b4 = bones[i].mPositionXYZ.y;
@ -656,9 +653,6 @@ void MD5Importer::LoadMD5AnimFile ()
MD5::ConvertQuaternion(vTemp, qKey->mValue);
qKey->mTime = vKey->mTime = dTime;
// we need this to get to Assimp quaternion conventions
qKey->mValue.w *= -1.f;
}
}

View File

@ -262,6 +262,9 @@ inline void ConvertQuaternion (const aiVector3D& in, aiQuaternion& out) {
if (t < 0.0f)
out.w = 0.0f;
else out.w = std::sqrt (t);
// Assimp convention.
out.w *= -1.f;
}
// ---------------------------------------------------------------------------