From 85f64c913145f63a394d0907ab65a45511e19bcc Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 28 Nov 2023 20:56:43 +0100 Subject: [PATCH] Use correct time scaling --- code/AssetLib/FBX/FBXExporter.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/code/AssetLib/FBX/FBXExporter.cpp b/code/AssetLib/FBX/FBXExporter.cpp index 2ea505618..28299544a 100644 --- a/code/AssetLib/FBX/FBXExporter.cpp +++ b/code/AssetLib/FBX/FBXExporter.cpp @@ -1061,14 +1061,14 @@ aiMatrix4x4 get_world_transform(const aiNode* node, const aiScene* scene) return transform; } -int64_t to_ktime(double ticks, const aiAnimation* anim) { +inline int64_t to_ktime(double ticks, const aiAnimation* anim) { if (anim->mTicksPerSecond <= 0) { return static_cast(ticks) * FBX::SECOND; } - return (static_cast(ticks) / static_cast(anim->mTicksPerSecond)) * FBX::SECOND; + return (static_cast(ticks / anim->mTicksPerSecond)) * FBX::SECOND; } -int64_t to_ktime(double time) { +inline int64_t to_ktime(double time) { return (static_cast(time * FBX::SECOND)); } @@ -2413,7 +2413,7 @@ void FBXExporter::WriteObjects () // position/translation for (size_t ki = 0; ki < na->mNumPositionKeys; ++ki) { const aiVectorKey& k = na->mPositionKeys[ki]; - times.push_back(to_ktime(k.mTime)); + times.push_back(to_ktime(k.mTime, anim)); xval.push_back(k.mValue.x); yval.push_back(k.mValue.y); zval.push_back(k.mValue.z); @@ -2427,7 +2427,7 @@ void FBXExporter::WriteObjects () times.clear(); xval.clear(); yval.clear(); zval.clear(); for (size_t ki = 0; ki < na->mNumRotationKeys; ++ki) { const aiQuatKey& k = na->mRotationKeys[ki]; - times.push_back(to_ktime(k.mTime)); + times.push_back(to_ktime(k.mTime, anim)); // TODO: aiQuaternion method to convert to Euler... aiMatrix4x4 m(k.mValue.GetMatrix()); aiVector3D qs, qr, qt; @@ -2445,7 +2445,7 @@ void FBXExporter::WriteObjects () times.clear(); xval.clear(); yval.clear(); zval.clear(); for (size_t ki = 0; ki < na->mNumScalingKeys; ++ki) { const aiVectorKey& k = na->mScalingKeys[ki]; - times.push_back(to_ktime(k.mTime)); + times.push_back(to_ktime(k.mTime, anim)); xval.push_back(k.mValue.x); yval.push_back(k.mValue.y); zval.push_back(k.mValue.z);