summaryrefslogtreecommitdiffstats
path: root/src/animation
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-03-18 15:41:24 +0000
committerSean Harmer <sean.harmer@kdab.com>2017-03-25 14:23:22 +0000
commitb18d39153453e6e2cab9e6c75bd2991aa25d0397 (patch)
tree32495680fcb26976b3046ad54fe0da69f073d51a /src/animation
parent982ea29558d6374067eb6cc0505b709eb9ecdae3 (diff)
Add function to format clip results using a gather operation
If an index in the format is -1 put a default value of 0 into the formatted results. This will allow clips to not have to provide every channel used anywhere by the blend tree. Change-Id: I9e18d0840e75a959ef680cbd54259a74c9331fa8 Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/animation')
-rw-r--r--src/animation/backend/animationutils.cpp18
-rw-r--r--src/animation/backend/animationutils_p.h4
2 files changed, 22 insertions, 0 deletions
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp
index 8f1a681d4..8b2ba6821 100644
--- a/src/animation/backend/animationutils.cpp
+++ b/src/animation/backend/animationutils.cpp
@@ -369,6 +369,24 @@ QVector<Qt3DCore::QNodeId> gatherValueNodesToEvaluate(Handler *handler,
return clipIds;
}
+ClipResults formatClipResults(const ClipResults &rawClipResults,
+ const ComponentIndices &format)
+{
+ // Resize the output to match the number of indices
+ const int elementCount = format.size();
+ ClipResults formattedClipResults(elementCount);
+
+ // Perform a gather operation to format the data
+ // TODO: For large numbers of components do this in parallel with
+ // for e.g. a parallel_for() like construct
+ for (int i = 0; i < elementCount; ++i) {
+ const float value = format[i] != -1 ? rawClipResults[format[i]] : 0.0f;
+ formattedClipResults[i] = value;
+ }
+
+ return formattedClipResults;
+}
+
ClipResults evaluateBlendTree(Handler *handler,
BlendedClipAnimator *animator,
Qt3DCore::QNodeId blendTreeRootId)
diff --git a/src/animation/backend/animationutils_p.h b/src/animation/backend/animationutils_p.h
index da85451f8..705e37c34 100644
--- a/src/animation/backend/animationutils_p.h
+++ b/src/animation/backend/animationutils_p.h
@@ -173,6 +173,10 @@ QVector<Qt3DCore::QNodeId> gatherValueNodesToEvaluate(Handler *handler,
Qt3DCore::QNodeId blendTreeRootId);
Q_AUTOTEST_EXPORT
+ClipResults formatClipResults(const ClipResults &rawClipResults,
+ const ComponentIndices &format);
+
+Q_AUTOTEST_EXPORT
ClipResults evaluateBlendTree(Handler *handler,
BlendedClipAnimator *animator,
Qt3DCore::QNodeId blendNodeId);