From 3a5b63c484070d672d142f01e49e74301a94e3e0 Mon Sep 17 00:00:00 2001 From: parax0 Date: Fri, 29 Apr 2016 19:08:32 -0600 Subject: [PATCH] Fixed incorrect scale decoding on compressed animations --- src/Core/Resource/CSkeleton.cpp | 2 +- src/Core/Resource/Factory/CAnimationLoader.cpp | 6 +++--- src/Core/Resource/Factory/CAnimationLoader.h | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Core/Resource/CSkeleton.cpp b/src/Core/Resource/CSkeleton.cpp index f745f40a..4906047f 100644 --- a/src/Core/Resource/CSkeleton.cpp +++ b/src/Core/Resource/CSkeleton.cpp @@ -23,7 +23,7 @@ void CBone::UpdateTransform(CBoneTransformData& rData, const SBoneTransformInfo& TransformInfo.Position = CVector3f::skZero; // Apply parent transform - TransformInfo.Position = rkParentTransform.Position + (rkParentTransform.Rotation * TransformInfo.Position); + TransformInfo.Position = rkParentTransform.Position + (rkParentTransform.Rotation * (rkParentTransform.Scale * TransformInfo.Position)); TransformInfo.Rotation = rkParentTransform.Rotation * TransformInfo.Rotation; // Calculate transform diff --git a/src/Core/Resource/Factory/CAnimationLoader.cpp b/src/Core/Resource/Factory/CAnimationLoader.cpp index e5b8da0a..6f9396df 100644 --- a/src/Core/Resource/Factory/CAnimationLoader.cpp +++ b/src/Core/Resource/Factory/CAnimationLoader.cpp @@ -212,7 +212,7 @@ void CAnimationLoader::ReadCompressedANIM() mRotationDivisor = mpInput->ReadLong(); mTranslationMultiplier = mpInput->ReadFloat(); - if (mGame == eEchoes) mpInput->Seek(0x4, SEEK_CUR); + if (mGame == eEchoes) mScaleMultiplier = mpInput->ReadFloat(); u32 NumBoneChannels = mpInput->ReadLong(); mpInput->Seek(0x4, SEEK_CUR); // Skip unknown value @@ -321,7 +321,7 @@ void CAnimationLoader::ReadCompressedAnimationData() if (rChan.NumScaleKeys > 0) { mpAnim->mScaleChannels[iChan].reserve(rChan.NumScaleKeys + 1); - CVector3f Scale = CVector3f(rChan.Scale[0], rChan.Scale[1], rChan.Scale[2]) / (float) mRotationDivisor; + CVector3f Scale = CVector3f(rChan.Scale[0], rChan.Scale[1], rChan.Scale[2]) * mScaleMultiplier; mpAnim->mScaleChannels[iChan].push_back(Scale); } } @@ -377,7 +377,7 @@ void CAnimationLoader::ReadCompressedAnimationData() rChan.Scale[2] += (s16) BitStream.ReadBits(rChan.ScaleBits[2]); } - CVector3f Scale = CVector3f(rChan.Scale[0], rChan.Scale[1], rChan.Scale[2]) / (float) mRotationDivisor; + CVector3f Scale = CVector3f(rChan.Scale[0], rChan.Scale[1], rChan.Scale[2]) * mScaleMultiplier; mpAnim->mScaleChannels[iChan].push_back(Scale); } } diff --git a/src/Core/Resource/Factory/CAnimationLoader.h b/src/Core/Resource/Factory/CAnimationLoader.h index 58ddfbfc..a4555c0a 100644 --- a/src/Core/Resource/Factory/CAnimationLoader.h +++ b/src/Core/Resource/Factory/CAnimationLoader.h @@ -15,6 +15,7 @@ class CAnimationLoader std::vector mKeyFlags; float mTranslationMultiplier; u32 mRotationDivisor; + float mScaleMultiplier; struct SCompressedChannel {