summaryrefslogtreecommitdiffstats
path: root/src/animation/backend/clipblendnode.cpp
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-03-17 17:16:06 +0000
committerSean Harmer <sean.harmer@kdab.com>2017-03-25 14:23:08 +0000
commit6961c308fb9d98006c98654a8131593f390c89a8 (patch)
treececa08b394bd3a66d63df6c1873f7a4871e35247 /src/animation/backend/clipblendnode.cpp
parent1da93b2fcf57dc442952b65d599db4e209faa59f (diff)
Add virtual doBlend to ClipBlendNode and subclasses
This is called by the non virtual performBlend (will be renamed once old implementation is removed). The key here is that all nodes in the blend tree will have the exact same layout for the ClipResults for a given animator. This means we don't need to have a mapping data structure for every node in the tree. This really simplifies the blending implementation and will allow us to parallelise this much better in the future as each blend node could make use of a parallel_for() or map() type operation. To achieve this we will need to perform a gather operation that maps the ClipResults coming straight out of an animation clip to the ClipResults layout used by the blend tree as described above. This will be done in a follow up commit. Change-Id: I389383d3b9197a6ef36b529f44ac89cb5c593023 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/animation/backend/clipblendnode.cpp')
-rw-r--r--src/animation/backend/clipblendnode.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/animation/backend/clipblendnode.cpp b/src/animation/backend/clipblendnode.cpp
index 18d57b0c7..f22df7b74 100644
--- a/src/animation/backend/clipblendnode.cpp
+++ b/src/animation/backend/clipblendnode.cpp
@@ -200,6 +200,34 @@ ClipResults ClipBlendNode::clipResults(Qt3DCore::QNodeId animatorId) const
evaluated in one pass, and the tree in a subsequent pass.
*/
+/*!
+ \internal
+
+ Fetches the ClipResults from the nodes listed in the dependencyIds
+ and passes them to the doBlend() virtual function which should be
+ implemented in subclasses to perform the actual blend operation.
+ The results are then inserted into the clip results for this blend
+ node indexed by the \a animatorId.
+*/
+void ClipBlendNode::performBlend(Qt3DCore::QNodeId animatorId)
+{
+ // Obtain the clip results from each of the dependencies
+ const QVector<Qt3DCore::QNodeId> dependencyNodeIds = dependencyIds();
+ const int dependencyCount = dependencyNodeIds.size();
+ QVector<ClipResults> blendData;
+ blendData.reserve(dependencyCount);
+ for (const auto dependencyId : dependencyNodeIds) {
+ ClipBlendNode *dependencyNode = clipBlendNodeManager()->lookupNode(dependencyId);
+ ClipResults blendDataElement = dependencyNode->clipResults(animatorId);
+ blendData.push_back(blendDataElement);
+ }
+
+ // Ask the blend node to perform the actual blend operation on the data
+ // from the dependencies
+ ClipResults blendedResults = doBlend(blendData);
+ setClipResults(animatorId, blendedResults);
+}
+
} // Animation
} // Qt3DAnimation