Merge branch 'master' into gltf_mesh_morph_animations

pull/2675/head
vcebollada 2019-10-01 08:04:46 +01:00 committed by GitHub
commit 6550b1df61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 39 deletions

View File

@ -1255,45 +1255,8 @@ void glTF2Importer::ImportAnimations(glTF2::Asset& r)
} }
} }
ai_anim->mDuration = static_cast<double>(maxNumberOfKeys - 1u); /// According the documentation in anim.h the mDuration units are ticks. ai_anim->mDuration = maxDuration;
ai_anim->mTicksPerSecond = (maxNumberOfKeys > 0 && maxDuration > 0) ? ((maxNumberOfKeys-1u) / (maxDuration / 1000.0)) : 30.0; ai_anim->mTicksPerSecond = 1000.0;
// Set all the times of the keys in ticks.
const float kMsToTicks = ai_anim->mTicksPerSecond / 1000.f;
for (unsigned int j = 0; j < ai_anim->mNumChannels; ++j) {
auto chan = ai_anim->mChannels[j];
if (0u != chan->mNumPositionKeys) {
for (unsigned int k = 0u; k < chan->mNumPositionKeys; ++k)
{
chan->mPositionKeys[k].mTime *= kMsToTicks;
}
}
if (0u != chan->mNumRotationKeys) {
for (unsigned int k = 0u; k < chan->mNumRotationKeys; ++k)
{
chan->mRotationKeys[k].mTime *= kMsToTicks;
}
}
if (0u != chan->mNumScalingKeys) {
for (unsigned int k = 0u; k < chan->mNumScalingKeys; ++k)
{
chan->mScalingKeys[k].mTime *= kMsToTicks;
}
}
}
for (unsigned int j = 0; j < ai_anim->mNumMorphMeshChannels; ++j) {
const auto* const chan = ai_anim->mMorphMeshChannels[j];
if (0u != chan->mNumKeys) {
for (unsigned int k = 0u; k < chan->mNumKeys; ++k)
{
chan->mKeys[k].mTime = static_cast<double>(k);
}
}
}
mScene->mAnimations[i] = ai_anim; mScene->mAnimations[i] = ai_anim;
} }