summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Harmer <sean.harmer@kdab.com>2017-03-15 18:36:01 +0000
committerSean Harmer <sean.harmer@kdab.com>2017-03-19 12:45:36 +0000
commitb5b0ce0df57fc67c100e64d9cac34dee46d7ae72 (patch)
treea7e962c7802777f09f69b15f1c0a68775131c1c6 /tests
parentb19e1cf6b03b7236c1c6bac8614eb41da8a915d8 (diff)
Add function to find set of leaf blend node ids that need evaluating
We should only evaluate the clips that are actually dependencies of the blend tree being evaluated given its current state. At present this will simply be the set of all leaf nodes in the blend tree but in the future when we support generalised lerp nodes etc, this will yield the subset needed for the current state. This involved adding support for pre-order traversal of the blend tree. As a result, extended the visitor to work with both pre and post orders and for all nodes or only the dependencies. Note that we return the ids of the blend tree nodes, not the ids of the clips themsevles. This is so we can then index the results by blend node id in a later commit. Change-Id: Ia13fe90ec3090306c1e8ade316ce0540f36a67fd Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/animationutils/tst_animationutils.cpp69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp
index 7c95b2117..534eb1678 100644
--- a/tests/auto/animation/animationutils/tst_animationutils.cpp
+++ b/tests/auto/animation/animationutils/tst_animationutils.cpp
@@ -31,7 +31,9 @@
#include <Qt3DAnimation/private/animationutils_p.h>
#include <Qt3DAnimation/private/channelmapper_p.h>
#include <Qt3DAnimation/private/channelmapping_p.h>
+#include <Qt3DAnimation/private/clipblendvalue_p.h>
#include <Qt3DAnimation/private/handler_p.h>
+#include <Qt3DAnimation/private/lerpclipblend_p.h>
#include <Qt3DAnimation/private/managers_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
#include <QtGui/qvector2d.h>
@@ -123,6 +125,28 @@ public:
return animator;
}
+ LerpClipBlend *createLerpClipBlend(Handler *handler)
+ {
+ auto lerpId = Qt3DCore::QNodeId::createId();
+ LerpClipBlend *lerp = new LerpClipBlend();
+ setPeerId(lerp, lerpId);
+ lerp->setClipBlendNodeManager(handler->clipBlendNodeManager());
+ lerp->setHandler(handler);
+ handler->clipBlendNodeManager()->appendNode(lerpId, lerp);
+ return lerp;
+ }
+
+ ClipBlendValue *createClipBlendValue(Handler *handler)
+ {
+ auto valueId = Qt3DCore::QNodeId::createId();
+ ClipBlendValue *value = new ClipBlendValue();
+ setPeerId(value, valueId);
+ value->setClipBlendNodeManager(handler->clipBlendNodeManager());
+ value->setHandler(handler);
+ handler->clipBlendNodeManager()->appendNode(valueId, value);
+ return value;
+ }
+
private Q_SLOTS:
void checkBuildPropertyMappings_data()
{
@@ -1481,6 +1505,51 @@ private Q_SLOTS:
// Cleanup
delete handler;
}
+
+ void checkGatherValueNodesToEvaluate_data()
+ {
+ QTest::addColumn<Handler *>("handler");
+ QTest::addColumn<Qt3DCore::QNodeId>("blendTreeRootId");
+ QTest::addColumn<QVector<Qt3DCore::QNodeId>>("expectedIds");
+
+ {
+ Handler *handler = new Handler;
+
+ const auto lerp = createLerpClipBlend(handler);
+ const auto value1 = createClipBlendValue(handler);
+ const auto clip1Id = Qt3DCore::QNodeId::createId();
+ value1->setClipId(clip1Id);
+ lerp->setStartClipId(value1->peerId());
+
+ const auto value2 = createClipBlendValue(handler);
+ const auto clip2Id = Qt3DCore::QNodeId::createId();
+ value2->setClipId(clip2Id);
+ lerp->setEndClipId(value2->peerId());
+
+ QVector<Qt3DCore::QNodeId> expectedIds = { value1->peerId(), value2->peerId() };
+
+ QTest::newRow("simple lerp") << handler << lerp->peerId() << expectedIds;
+ }
+ }
+
+ void checkGatherValueNodesToEvaluate()
+ {
+ // GIVEN
+ QFETCH(Handler *, handler);
+ QFETCH(Qt3DCore::QNodeId, blendTreeRootId);
+ QFETCH(QVector<Qt3DCore::QNodeId>, expectedIds);
+
+ // WHEN
+ QVector<Qt3DCore::QNodeId> actualIds = gatherValueNodesToEvaluate(handler, blendTreeRootId);
+
+ // THEN
+ QCOMPARE(actualIds.size(), expectedIds.size());
+ for (int i = 0; i < actualIds.size(); ++i)
+ QCOMPARE(actualIds[i], expectedIds[i]);
+
+ // Cleanup
+ delete handler;
+ }
};
QTEST_MAIN(tst_AnimationUtils)