diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-09-22 13:47:59 +0100 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-09-26 10:53:14 +0000 |
commit | 8f2ced29ceedacd2f23f19af1813a5f351b43eec (patch) | |
tree | b41134d97a4bd3aabc597d60196806a5b6390bc8 | |
parent | a56240c13ea84f678085131e7ee52c2402361a07 (diff) |
Actually get matching clip indices for components
Rather than assuming they are in order. The blended clip animator
code path now behaves the same as the simple QClipAnimator in
that it can handle clips with channel components not in the
expected order. We can now look at making both share a common
code path.
Change-Id: I61848e07b4f418ba9f4c56f56f4f49c9a5fbd588
Reviewed-by: Kevin Ottens <kevin.ottens@kdab.com>
-rw-r--r-- | src/animation/backend/animationutils.cpp | 13 | ||||
-rw-r--r-- | tests/auto/animation/animationutils/tst_animationutils.cpp | 16 |
2 files changed, 14 insertions, 15 deletions
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index db49078cf..4d9fc4d30 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -502,7 +502,6 @@ ComponentIndices generateClipFormatIndices(const QVector<ChannelNameAndType> &ta ComponentIndices format; format.resize(indexCount); - // Iterate through the target channels const int channelCount = targetChannels.size(); auto formatIt = format.begin(); @@ -510,18 +509,18 @@ ComponentIndices generateClipFormatIndices(const QVector<ChannelNameAndType> &ta // Find the index of the channel from the clip const ChannelNameAndType &targetChannel = targetChannels[i]; const int clipChannelIndex = clip->channelIndex(targetChannel.name); - - // TODO: Ensure channel in the clip has enough components to map to the type. - // Requires some improvements to the clip data structure first. - // TODO: I don't think we need the targetIndices, only the number of components - // for each target channel. Check once blend tree is complete. const int componentCount = targetIndices[i].size(); if (clipChannelIndex != -1) { // Found a matching channel in the clip. Get the base channel // component index and populate the format indices for this channel. const int baseIndex = clip->channelComponentBaseIndex(clipChannelIndex); - std::iota(formatIt, formatIt + componentCount, baseIndex); + + // Within this group, match channel names with index ordering + const auto channelIndices = channelComponentsToIndices(clip->channels()[clipChannelIndex], + targetChannel.type, + baseIndex); + std::copy(channelIndices.begin(), channelIndices.end(), formatIt); } else { // No such channel in this clip. We'll use default values when diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp index 068db7ac6..e1c52ed10 100644 --- a/tests/auto/animation/animationutils/tst_animationutils.cpp +++ b/tests/auto/animation/animationutils/tst_animationutils.cpp @@ -2489,8 +2489,8 @@ private Q_SLOTS: clip->setSource(QUrl("qrc:/clip3.json")); clip->loadAnimation(); - ComponentIndices expectedResults = { 0, 1, 2, 3, // Rotation - 4, 5, 6, // Location + ComponentIndices expectedResults = { 0, 1, 3, 2, // Rotation (y/z swapped in clip3.json) + 4, 6, 5, // Location (y/z swapped in clip3.json) 7, 8, 9, // Base Color 10, // Metalness 11 }; // Roughness @@ -2519,8 +2519,8 @@ private Q_SLOTS: clip->setSource(QUrl("qrc:/clip3.json")); clip->loadAnimation(); - ComponentIndices expectedResults = { 4, 5, 6, // Location - 0, 1, 2, 3, // Rotation + ComponentIndices expectedResults = { 4, 6, 5, // Location (y/z swapped in clip3.json) + 0, 1, 3, 2, // Rotation (y/z swapped in clip3.json) 7, 8, 9, // Base Color 10, // Metalness 11 }; // Roughness @@ -2549,8 +2549,8 @@ private Q_SLOTS: clip->setSource(QUrl("qrc:/clip3.json")); clip->loadAnimation(); - ComponentIndices expectedResults = { 0, 1, 2, 3, // Rotation - 4, 5, 6, // Location + ComponentIndices expectedResults = { 0, 1, 3, 2, // Rotation (y/z swapped in clip3.json) + 4, 6, 5, // Location (y/z swapped in clip3.json) -1, -1, -1, // Albedo (missing from clip) 10, // Metalness 11 }; // Roughness @@ -2579,8 +2579,8 @@ private Q_SLOTS: clip->setSource(QUrl("qrc:/clip3.json")); clip->loadAnimation(); - ComponentIndices expectedResults = { 4, 5, 6, // Location - 0, 1, 2, 3, // Rotation + ComponentIndices expectedResults = { 4, 6, 5, // Location (y/z swapped in clip3.json) + 0, 1, 3, 2, // Rotation (y/z swapped in clip3.json) -1, -1, -1, // Albedo (missing from clip) 10, // Metalness 11 }; // Roughness |