From c2297e91999794f44862101114c7b0de651eda01 Mon Sep 17 00:00:00 2001 From: Inho Lee Date: Wed, 8 Dec 2021 13:45:35 +0100 Subject: [PATCH] Revert "FBXConverter : Fix timescales of FBX animations" The previous patch was made by misunderstanding about mTime. It is not real time value, but time ticks. This reverts commit b8bf1eac041f0bbb406019a28f310509dad51b86. --- code/AssetLib/FBX/FBXConverter.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/code/AssetLib/FBX/FBXConverter.cpp b/code/AssetLib/FBX/FBXConverter.cpp index 098ba58e2..5a3ae0ae7 100644 --- a/code/AssetLib/FBX/FBXConverter.cpp +++ b/code/AssetLib/FBX/FBXConverter.cpp @@ -79,7 +79,7 @@ using namespace Util; #define MAGIC_NODE_TAG "_$AssimpFbx$" -#define CONVERT_FBX_TIME(time) (static_cast(time) * 1000.0 / 46186158000LL) +#define CONVERT_FBX_TIME(time) static_cast(time) / 46186158000LL FBXConverter::FBXConverter(aiScene *out, const Document &doc, bool removeEmptyBones) : defaultMaterialIndex(), @@ -2618,7 +2618,7 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) { meshMorphAnim->mKeys[j].mNumValuesAndWeights = numValuesAndWeights; meshMorphAnim->mKeys[j].mValues = new unsigned int[numValuesAndWeights]; meshMorphAnim->mKeys[j].mWeights = new double[numValuesAndWeights]; - meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first); + meshMorphAnim->mKeys[j].mTime = CONVERT_FBX_TIME(animIt.first) * anim_fps; for (unsigned int k = 0; k < numValuesAndWeights; k++) { meshMorphAnim->mKeys[j].mValues[k] = keyData->values.at(k); meshMorphAnim->mKeys[j].mWeights[k] = keyData->weights.at(k); @@ -2636,8 +2636,8 @@ void FBXConverter::ConvertAnimationStack(const AnimationStack &st) { return; } - double start_time_fps = has_local_startstop ? CONVERT_FBX_TIME(start_time) : min_time; - double stop_time_fps = has_local_startstop ? CONVERT_FBX_TIME(stop_time) : max_time; + double start_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(start_time) * anim_fps) : min_time; + double stop_time_fps = has_local_startstop ? (CONVERT_FBX_TIME(stop_time) * anim_fps) : max_time; // adjust relative timing for animation for (unsigned int c = 0; c < anim->mNumChannels; c++) { @@ -3162,7 +3162,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name, InterpolateKeys(outTranslations, keytimes, keyframeLists[TransformationComp_Translation], defTranslate, maxTime, minTime); } else { for (size_t i = 0; i < keyCount; ++i) { - outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]); + outTranslations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps; outTranslations[i].mValue = defTranslate; } } @@ -3171,7 +3171,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name, InterpolateKeys(outRotations, keytimes, keyframeLists[TransformationComp_Rotation], defRotation, maxTime, minTime, rotOrder); } else { for (size_t i = 0; i < keyCount; ++i) { - outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]); + outRotations[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps; outRotations[i].mValue = defQuat; } } @@ -3180,7 +3180,7 @@ aiNodeAnim* FBXConverter::GenerateSimpleNodeAnim(const std::string& name, InterpolateKeys(outScales, keytimes, keyframeLists[TransformationComp_Scaling], defScale, maxTime, minTime); } else { for (size_t i = 0; i < keyCount; ++i) { - outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]); + outScales[i].mTime = CONVERT_FBX_TIME(keytimes[i]) * anim_fps; outScales[i].mValue = defScale; } } @@ -3442,7 +3442,7 @@ void FBXConverter::InterpolateKeys(aiVectorKey *valOut, const KeyTimeList &keys, } // magic value to convert fbx times to seconds - valOut->mTime = CONVERT_FBX_TIME(time); + valOut->mTime = CONVERT_FBX_TIME(time) * anim_fps; min_time = std::min(min_time, valOut->mTime); max_time = std::max(max_time, valOut->mTime);