diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-03-23 12:25:12 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-25 14:23:41 +0000 |
commit | 63aa2898615bffb37a3d9f949b089b2ac2bf2737 (patch) | |
tree | eef54c89332c98d506f6a0fda20666d0f27023a5 /src | |
parent | 37fd551490035a2004e4151857b2f7fd35078b97 (diff) |
Add overload of buildPropertyMappings
Eventually we should remove the original form which is currently
called by the non-blended animation code path. It will be better to
merge the blended and non-blended code paths so we have less code to
maintain. Also the blended code path seems more efficient.
Change-Id: Ib6aa4006e4b830a32b985527bae900ce6f3facec
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/animation/backend/animationutils.cpp | 36 | ||||
-rw-r--r-- | src/animation/backend/animationutils_p.h | 6 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index 677db5d00..b9948320c 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -290,6 +290,8 @@ QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId anim return changes; } +//TODO: Remove this and use new implementation below for both the unblended +// and blended animation cases. QVector<MappingData> buildPropertyMappings(Handler *handler, const AnimationClipLoader *clip, const ChannelMapper *mapper) @@ -343,6 +345,40 @@ QVector<MappingData> buildPropertyMappings(Handler *handler, return mappingDataVec; } +QVector<MappingData> buildPropertyMappings(const QVector<ChannelMapping*> &channelMappings, + const QVector<ChannelNameAndType> &channelNamesAndTypes, + const QVector<ComponentIndices> &channelComponentIndices) +{ + QVector<MappingData> mappingDataVec; + mappingDataVec.reserve(channelMappings.size()); + + // Iterate over the mappings + for (const auto mapping : channelMappings) { + // Populate the data we need, easy stuff first + MappingData mappingData; + mappingData.targetId = mapping->targetId(); + mappingData.propertyName = mapping->propertyName(); + mappingData.type = mapping->type(); + + if (mappingData.type == static_cast<int>(QVariant::Invalid)) { + qWarning() << "Unknown type for node id =" << mappingData.targetId + << "and property =" << mapping->property(); + continue; + } + + // Try to find matching channel name and type + const ChannelNameAndType nameAndType = { mapping->channelName(), mapping->type() }; + const int index = channelNamesAndTypes.indexOf(nameAndType); + if (index != -1) { + // We got one! + mappingData.channelIndices = channelComponentIndices[index]; + mappingDataVec.push_back(mappingData); + } + } + + return mappingDataVec; +} + QVector<ChannelNameAndType> buildRequiredChannelsAndTypes(Handler *handler, const ChannelMapper *mapper) { diff --git a/src/animation/backend/animationutils_p.h b/src/animation/backend/animationutils_p.h index 7ec611633..4e56f9d95 100644 --- a/src/animation/backend/animationutils_p.h +++ b/src/animation/backend/animationutils_p.h @@ -62,6 +62,7 @@ class BlendedClipAnimator; class Handler; class AnimationClipLoader; class ChannelMapper; +class ChannelMapping; typedef QVector<int> ComponentIndices; @@ -173,6 +174,11 @@ QVector<MappingData> buildPropertyMappings(Handler *handler, const ChannelMapper *mapper); Q_AUTOTEST_EXPORT +QVector<MappingData> buildPropertyMappings(const QVector<ChannelMapping *> &channelMappings, + const QVector<ChannelNameAndType> &channelNamesAndTypes, + const QVector<ComponentIndices> &channelComponentIndices); + +Q_AUTOTEST_EXPORT QVector<ChannelNameAndType> buildRequiredChannelsAndTypes(Handler *handler, const ChannelMapper *mapper); |