diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-03-20 13:42:53 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-25 14:23:28 +0000 |
commit | 1929b3e48c0a327e7a741275d6d4847b72ddf704 (patch) | |
tree | 703782cb36b3979929b0d440550bfe337bb925a7 /src/animation/backend/animationutils.cpp | |
parent | b18d39153453e6e2cab9e6c75bd2991aa25d0397 (diff) |
Add a function to build list of unique channel names and types
This will be needed to construct the data layout for blend trees.
Change-Id: I0b11076f5ecd55cfad094d864f3f8270841fc62a
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/animation/backend/animationutils.cpp')
-rw-r--r-- | src/animation/backend/animationutils.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index 8b2ba6821..d79b412fd 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -335,6 +335,37 @@ QVector<MappingData> buildPropertyMappings(Handler *handler, return mappingDataVec; } +QVector<ChannelNameAndType> buildRequiredChannelsAndTypes(Handler *handler, + const ChannelMapper *mapper) +{ + ChannelMappingManager *mappingManager = handler->channelMappingManager(); + const QVector<Qt3DCore::QNodeId> mappingIds = mapper->mappingIds(); + + // Reserve enough storage assuming each mapping is for a different channel. + // May be overkill but avoids potential for multiple allocations + QVector<ChannelNameAndType> namesAndTypes; + namesAndTypes.reserve(mappingIds.size()); + + // Iterate through the mappings and add ones not already used by an earlier mapping. + // We could add them all then sort and remove duplicates. However, our approach has the + // advantage of keeping the blend tree format more consistent with the mapping + // orderings which will have better cache locality when generating events. + for (const Qt3DCore::QNodeId mappingId : mappingIds) { + // Get the mapping object + ChannelMapping *mapping = mappingManager->lookupResource(mappingId); + Q_ASSERT(mapping); + + // Get the name and type + const ChannelNameAndType nameAndType{ mapping->channelName(), mapping->type() }; + + // Add if not already contained + if (!namesAndTypes.contains(nameAndType)) + namesAndTypes.push_back(nameAndType); + } + + return namesAndTypes; +} + QVector<Qt3DCore::QNodeId> gatherValueNodesToEvaluate(Handler *handler, Qt3DCore::QNodeId blendTreeRootId) { |