summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-03-18 15:07:11 +0000
committerSean Harmer <sean.harmer@kdab.com>2017-03-25 14:23:18 +0000
commit982ea29558d6374067eb6cc0505b709eb9ecdae3 (patch)
treed42c780087e1dc5675ff4e45abb3a6bdc0c71697 /src
parent8a5f83749373f5f3dc3490563ee437253ba59414 (diff)
Add methods to set and retrieve format indices for a blend value node
In order to have a consistent data layout for all interior nodes of a blend tree, we need a place to convert from whatever data layout a clip produces when evaluated to the format used by the blend tree. We will do this by creating for each value leaf node a vector of indices that can be used to map from the ClipResults layout output by the clip to the ClipResults format used by the blend tree. With this approach, we can do the following: * Evaluate each leaf node in the blend tree * Perform a gather operation using these format indices to reorder the data into a consistent layout for the whole blend tree * Evaluate the blend tree using this consistent layout This completely avoids having to perform complex mappings when evaluating each blend node, which is a significant saving in overhead and allows for more parallellism in the future. Change-Id: Ie534534f9555842d0d0f1a89fc996e25f5c6ce9e Reviewed-by: Paul Lemire <paul.lemire@kdab.com> Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src')
-rw-r--r--src/animation/backend/clipblendvalue.cpp21
-rw-r--r--src/animation/backend/clipblendvalue_p.h6
2 files changed, 27 insertions, 0 deletions
diff --git a/src/animation/backend/clipblendvalue.cpp b/src/animation/backend/clipblendvalue.cpp
index a1726a40a..d3970c24b 100644
--- a/src/animation/backend/clipblendvalue.cpp
+++ b/src/animation/backend/clipblendvalue.cpp
@@ -98,6 +98,27 @@ double ClipBlendValue::duration() const
return clip->duration();
}
+void ClipBlendValue::setFormatIndices(Qt3DCore::QNodeId animatorId, const ComponentIndices &formatIndices)
+{
+ // Do we already have an entry for this animator?
+ const int animatorIndex = m_animatorIds.indexOf(animatorId);
+ if (animatorIndex == -1) {
+ // Nope, add it
+ m_animatorIds.push_back(animatorId);
+ m_formatIndicies.push_back(formatIndices);
+ } else {
+ m_formatIndicies[animatorIndex] = formatIndices;
+ }
+}
+
+ComponentIndices ClipBlendValue::formatIndices(Qt3DCore::QNodeId animatorId)
+{
+ const int animatorIndex = m_animatorIds.indexOf(animatorId);
+ if (animatorIndex != -1)
+ return m_formatIndicies[animatorIndex];
+ return ComponentIndices();
+}
+
} // namespace Animation
} // namespace Qt3DAnimation
diff --git a/src/animation/backend/clipblendvalue_p.h b/src/animation/backend/clipblendvalue_p.h
index f06800488..21cc4adf3 100644
--- a/src/animation/backend/clipblendvalue_p.h
+++ b/src/animation/backend/clipblendvalue_p.h
@@ -74,6 +74,9 @@ public:
double duration() const Q_DECL_OVERRIDE;
+ void setFormatIndices(Qt3DCore::QNodeId animatorId, const ComponentIndices &formatIndices);
+ ComponentIndices formatIndices(Qt3DCore::QNodeId animatorId);
+
protected:
ClipResults doBlend(const QVector<ClipResults> &blendData) const Q_DECL_OVERRIDE;
@@ -81,6 +84,9 @@ private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_FINAL;
Qt3DCore::QNodeId m_clipId;
+
+ QVector<Qt3DCore::QNodeId> m_animatorIds;
+ QVector<ComponentIndices> m_formatIndicies;
};
} // namespace Animation