summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-03-28 08:31:42 +0100
committerPaul Lemire <paul.lemire@kdab.com>2019-04-03 13:00:08 +0000
commitf0f5a2de1da2e05e3587d2a6486687ebbe649339 (patch)
tree80cfacbe85d1a88571c169d38dc495b3df687937 /tests
parent03234c59244ed77cb8eea5fca6b93741f40ca59d (diff)
Animations: handle variable length properties
For that we know determine the expected number of channel components for a given property in the frontend where we have access to both the type and the value rather than in the backend using the type only. Change-Id: I75aca20d43dd1b3db316c303af041acd557c07e4 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/animation/animation.pro4
-rw-r--r--tests/auto/animation/animationutils/tst_animationutils.cpp367
-rw-r--r--tests/auto/animation/channelmapping/tst_channelmapping.cpp53
-rw-r--r--tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp16
-rw-r--r--tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp161
5 files changed, 499 insertions, 102 deletions
diff --git a/tests/auto/animation/animation.pro b/tests/auto/animation/animation.pro
index 1226f9498..c600da690 100644
--- a/tests/auto/animation/animation.pro
+++ b/tests/auto/animation/animation.pro
@@ -5,7 +5,6 @@ SUBDIRS += \
qanimationcliploader \
qclipanimator \
qblendedclipanimator \
- qchannelmapping \
qchannelmapper \
qclipblendvalue \
qanimationcontroller \
@@ -40,5 +39,6 @@ qtConfig(private_tests) {
qabstractanimation \
clock \
skeleton \
- findrunningclipanimatorsjob
+ findrunningclipanimatorsjob \
+ qchannelmapping
}
diff --git a/tests/auto/animation/animationutils/tst_animationutils.cpp b/tests/auto/animation/animationutils/tst_animationutils.cpp
index ee393b366..7a7abb1b3 100644
--- a/tests/auto/animation/animationutils/tst_animationutils.cpp
+++ b/tests/auto/animation/animationutils/tst_animationutils.cpp
@@ -147,7 +147,8 @@ public:
const Qt3DCore::QNodeId targetId,
const QString &property,
const char *propertyName,
- int type)
+ int type,
+ int componentCount)
{
auto channelMappingId = Qt3DCore::QNodeId::createId();
ChannelMapping *channelMapping = handler->channelMappingManager()->getOrCreateResource(channelMappingId);
@@ -159,6 +160,7 @@ public:
channelMapping->setChannelName(channelName);
channelMapping->setType(type);
channelMapping->setMappingType(ChannelMapping::ChannelMappingType);
+ channelMapping->setComponentCount(componentCount);
return channelMapping;
}
@@ -292,28 +294,43 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
QVector<ChannelMapping *> channelMappings = { channelMapping };
// Create a few channels in the format description
ChannelNameAndType rotation = { QLatin1String("Rotation"),
static_cast<int>(QVariant::Quaternion),
+ 4,
channelMapping->peerId() };
ChannelNameAndType location = { QLatin1String("Location"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping->peerId() };
ChannelNameAndType baseColor = { QLatin1String("BaseColor"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping->peerId() };
ChannelNameAndType metalness = { QLatin1String("Metalness"),
static_cast<int>(QVariant::Double),
+ 1,
channelMapping->peerId() };
ChannelNameAndType roughness = { QLatin1String("Roughness"),
static_cast<int>(QVariant::Double),
+ 1,
channelMapping->peerId() };
+ ChannelNameAndType morphTargetWeightsList = { QLatin1String("MorphTargetWeightsList"),
+ static_cast<int>(QVariant::List),
+ 5,
+ channelMapping->peerId() };
+ ChannelNameAndType morphTargetWeightsVec = { QLatin1String("MorphTargetWeightsVec"),
+ qMetaTypeId<QVector<float>>(),
+ 6,
+ channelMapping->peerId() };
QVector<ChannelNameAndType> channelNamesAndTypes
- = { rotation, location, baseColor, metalness, roughness };
+ = { rotation, location, baseColor, metalness, roughness,
+ morphTargetWeightsList, morphTargetWeightsVec };
// And the matching indices
ComponentIndices rotationIndices = { 0, 1, 2, 3 };
@@ -321,15 +338,20 @@ private Q_SLOTS:
ComponentIndices baseColorIndices = { 7, 8, 9 };
ComponentIndices metalnessIndices = { 10 };
ComponentIndices roughnessIndices = { 11 };
+ ComponentIndices morphTargetListIndices = { 12, 13, 14, 15, 16 };
+ ComponentIndices morphTargetVecIndices = { 17, 18, 19, 20, 21, 22 };
QVector<ComponentIndices> channelComponentIndices
= { rotationIndices, locationIndices, baseColorIndices,
- metalnessIndices, roughnessIndices };
+ metalnessIndices, roughnessIndices, morphTargetListIndices,
+ morphTargetVecIndices };
QVector<QBitArray> sourceClipMask = { QBitArray(4, true),
QBitArray(3, true),
QBitArray(3, true),
QBitArray(1, true),
- QBitArray(1, true) };
+ QBitArray(1, true),
+ QBitArray(5, true),
+ QBitArray(6, true) };
MappingData expectedMapping;
expectedMapping.targetId = channelMapping->targetId();
@@ -356,59 +378,83 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
auto metalnessMapping = createChannelMapping(handler,
QLatin1String("Metalness"),
Qt3DCore::QNodeId::createId(),
QLatin1String("metalness"),
"metalness",
- static_cast<int>(QVariant::Double));
+ static_cast<int>(QVariant::Double),
+ 1);
auto baseColorMapping = createChannelMapping(handler,
QLatin1String("BaseColor"),
Qt3DCore::QNodeId::createId(),
QLatin1String("baseColor"),
"baseColor",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
auto roughnessMapping = createChannelMapping(handler,
QLatin1String("Roughness"),
Qt3DCore::QNodeId::createId(),
QLatin1String("roughness"),
"roughness",
- static_cast<int>(QVariant::Double));
+ static_cast<int>(QVariant::Double),
+ 1);
auto rotationMapping = createChannelMapping(handler,
QLatin1String("Rotation"),
Qt3DCore::QNodeId::createId(),
QLatin1String("rotation"),
"rotation",
- static_cast<int>(QVariant::Quaternion));
+ static_cast<int>(QVariant::Quaternion),
+ 4);
+
+ auto morphTargetMapping = createChannelMapping(handler,
+ QLatin1String("MorphTargetWeights"),
+ Qt3DCore::QNodeId::createId(),
+ QLatin1String("weights"),
+ "weights",
+ static_cast<int>(QVariant::List),
+ 5);
+
QVector<ChannelMapping *> channelMappings
= { locationMapping, metalnessMapping,
baseColorMapping, roughnessMapping,
- rotationMapping };
+ rotationMapping, morphTargetMapping };
// Create a few channels in the format description
ChannelNameAndType rotation = { QLatin1String("Rotation"),
static_cast<int>(QVariant::Quaternion),
+ 4,
rotationMapping->peerId() };
ChannelNameAndType location = { QLatin1String("Location"),
static_cast<int>(QVariant::Vector3D),
+ 3,
locationMapping->peerId() };
ChannelNameAndType baseColor = { QLatin1String("BaseColor"),
static_cast<int>(QVariant::Vector3D),
+ 3,
baseColorMapping->peerId() };
ChannelNameAndType metalness = { QLatin1String("Metalness"),
static_cast<int>(QVariant::Double),
+ 1,
metalnessMapping->peerId() };
ChannelNameAndType roughness = { QLatin1String("Roughness"),
static_cast<int>(QVariant::Double),
+ 1,
roughnessMapping->peerId() };
+ ChannelNameAndType morphTarget = { QLatin1String("MorphTargetWeights"),
+ static_cast<int>(QVariant::List),
+ 5,
+ morphTargetMapping->peerId() };
QVector<ChannelNameAndType> channelNamesAndTypes
- = { rotation, location, baseColor, metalness, roughness };
+ = { rotation, location, baseColor, metalness, roughness,
+ morphTarget };
// And the matching indices
ComponentIndices rotationIndices = { 0, 1, 2, 3 };
@@ -416,15 +462,17 @@ private Q_SLOTS:
ComponentIndices baseColorIndices = { 7, 8, 9 };
ComponentIndices metalnessIndices = { 10 };
ComponentIndices roughnessIndices = { 11 };
+ ComponentIndices morphTargetIndices = { 12, 13, 14, 15, 16 };
QVector<ComponentIndices> channelComponentIndices
= { rotationIndices, locationIndices, baseColorIndices,
- metalnessIndices, roughnessIndices };
+ metalnessIndices, roughnessIndices, morphTargetIndices };
QVector<QBitArray> sourceClipMask = { QBitArray(4, true),
QBitArray(3, true),
QBitArray(3, true),
QBitArray(1, true),
- QBitArray(1, true) };
+ QBitArray(1, true),
+ QBitArray(5, true) };
MappingData expectedLocationMapping;
expectedLocationMapping.targetId = locationMapping->targetId();
@@ -456,12 +504,19 @@ private Q_SLOTS:
expectedRotationMapping.type = rotationMapping->type();
expectedRotationMapping.channelIndices = rotationIndices;
+ MappingData expectedMorphTargetMapping;
+ expectedMorphTargetMapping.targetId = morphTargetMapping->targetId();
+ expectedMorphTargetMapping.propertyName = morphTargetMapping->propertyName();
+ expectedMorphTargetMapping.type = morphTargetMapping->type();
+ expectedMorphTargetMapping.channelIndices = morphTargetIndices;
+
QVector<MappingData> expectedResults
= { expectedLocationMapping,
expectedMetalnessMapping,
expectedBaseColorMapping,
expectedRoughnessMapping,
- expectedRotationMapping };
+ expectedRotationMapping,
+ expectedMorphTargetMapping };
QTest::newRow("multiple mappings")
<< handler
@@ -486,6 +541,7 @@ private Q_SLOTS:
for (int i = 0; i < jointCount; ++i) {
ChannelNameAndType locationDescription = { QLatin1String("Location"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping->peerId() };
locationDescription.jointIndex = i;
locationDescription.jointTransformComponent = Translation;
@@ -493,6 +549,7 @@ private Q_SLOTS:
ChannelNameAndType rotationDescription = { QLatin1String("Rotation"),
static_cast<int>(QVariant::Quaternion),
+ 4,
channelMapping->peerId() };
rotationDescription.jointIndex = i;
rotationDescription.jointTransformComponent = Rotation;
@@ -500,6 +557,7 @@ private Q_SLOTS:
ChannelNameAndType scaleDescription = { QLatin1String("Scale"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping->peerId() };
scaleDescription.jointIndex = i;
scaleDescription.jointTransformComponent = Scale;
@@ -1004,6 +1062,35 @@ private Q_SLOTS:
expectedChanges.clear();
}
+ // Single property, QVariantList
+ {
+ animatorId = Qt3DCore::QNodeId::createId();
+ MappingData mapping;
+ mapping.targetId = Qt3DCore::QNodeId::createId();
+ mapping.propertyName = "weights";
+ mapping.type = static_cast<int>(QVariant::List);
+ mapping.channelIndices = QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5 << 6;
+ mappingData.push_back(mapping);
+ channelResults = QVector<float>() << 0.5f << 0.4f << 0.3f << 0.0f << 1.0f << 0.6f << 0.9f;
+ finalFrame = false;
+ normalizedTime = 1.1f; // Invalid
+
+ auto change = Qt3DCore::QPropertyUpdatedChangePtr::create(mapping.targetId);
+ change->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll);
+ change->setPropertyName(mapping.propertyName);
+ QVariantList expectedValue = QVariantList() << 0.5f << 0.4f << 0.3f << 0.0f << 1.0f << 0.6f << 0.9f;
+ change->setValue(QVariant::fromValue(expectedValue));
+ expectedChanges.push_back(change);
+
+ QTest::newRow("QVariantList weights")
+ << animatorId << mappingData << channelResults << normalizedTime
+ << finalFrame << expectedChanges;
+
+ mappingData.clear();
+ channelResults.clear();
+ expectedChanges.clear();
+ }
+
}
void checkPreparePropertyChanges()
@@ -1396,12 +1483,14 @@ private Q_SLOTS:
{
QTest::addColumn<Channel>("channel");
QTest::addColumn<int>("dataType");
+ QTest::addColumn<int>("expectedChannelComponentCount");
QTest::addColumn<int>("offset");
QTest::addColumn<QVector<char>>("suffixes");
QTest::addColumn<QVector<int>>("expectedResults");
Channel channel;
int dataType;
+ int expectedChannelComponentCount;
int offset;
QVector<char> suffixes;
QVector<int> expectedResults;
@@ -1414,20 +1503,22 @@ private Q_SLOTS:
// leave 'name' empty
dataType = static_cast<int>(QVariant::Vector3D);
+ expectedChannelComponentCount = 3;
offset = 0;
// suffixes expected to be ignored
expectedResults = (QVector<int>() << 0 << 1 << 2);
QTest::newRow("vec3 location, pre-sorted, no component names, offset = 0")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
expectedResults.clear();
offset = 4;
expectedResults = (QVector<int>() << 4 << 5 << 6);
QTest::newRow("vec3 location, pre-sorted, no component names, offset = 4")
- << channel << dataType << offset << suffixes << expectedResults;
-
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
expectedResults.clear();
}
@@ -1441,19 +1532,22 @@ private Q_SLOTS:
channel.channelComponents[2].name = QLatin1String("Location Z");
dataType = static_cast<int>(QVariant::Vector3D);
+ expectedChannelComponentCount = 3;
offset = 0;
suffixes = (QVector<char>() << 'X' << 'Y' << 'Z' << 'W');
expectedResults = (QVector<int>() << 0 << 1 << 2);
QTest::newRow("vec3 location, offset = 0")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
expectedResults.clear();
offset = 4;
expectedResults = (QVector<int>() << 4 << 5 << 6);
QTest::newRow("vec3 location, offset = 4")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
suffixes.clear();
expectedResults.clear();
@@ -1468,19 +1562,22 @@ private Q_SLOTS:
channel.channelComponents[1].name = QLatin1String("pos Y");
dataType = static_cast<int>(QVariant::Vector2D);
+ expectedChannelComponentCount = 2;
offset = 0;
suffixes = (QVector<char>() << 'X' << 'Y' << 'Z' << 'W');
expectedResults = (QVector<int>() << 0 << 1);
QTest::newRow("vec2 pos, offset = 0")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
expectedResults.clear();
offset = 2;
expectedResults = (QVector<int>() << 2 << 3);
QTest::newRow("vec2 pos, offset = 2")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
suffixes.clear();
expectedResults.clear();
@@ -1497,19 +1594,22 @@ private Q_SLOTS:
channel.channelComponents[3].name = QLatin1String("foo W");
dataType = static_cast<int>(QVariant::Vector4D);
+ expectedChannelComponentCount = 4;
offset = 0;
suffixes = (QVector<char>() << 'X' << 'Y' << 'Z' << 'W');
expectedResults = (QVector<int>() << 0 << 1 << 2 << 3);
QTest::newRow("vec4 foo, offset = 0")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
expectedResults.clear();
offset = 10;
expectedResults = (QVector<int>() << 10 << 11 << 12 << 13);
QTest::newRow("vec4 foo, offset = 10")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
suffixes.clear();
expectedResults.clear();
@@ -1523,19 +1623,22 @@ private Q_SLOTS:
channel.channelComponents[0].name = QLatin1String("Mass X");
dataType = static_cast<int>(QVariant::Double);
+ expectedChannelComponentCount = 1;
offset = 0;
suffixes = (QVector<char>() << 'X' << 'Y' << 'Z' << 'W');
expectedResults = (QVector<int>() << 0);
QTest::newRow("double Mass, offset = 0")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
expectedResults.clear();
offset = 5;
expectedResults = (QVector<int>() << 5);
QTest::newRow("double Mass, offset = 5")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
suffixes.clear();
expectedResults.clear();
@@ -1552,19 +1655,22 @@ private Q_SLOTS:
channel.channelComponents[3].name = QLatin1String("Rotation Z");
dataType = static_cast<int>(QVariant::Quaternion);
+ expectedChannelComponentCount = 4;
offset = 0;
suffixes = (QVector<char>() << 'W' << 'X' << 'Y' << 'Z');
expectedResults = (QVector<int>() << 0 << 1 << 2 << 3);
QTest::newRow("quaternion Rotation, offset = 0")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
expectedResults.clear();
offset = 10;
expectedResults = (QVector<int>() << 10 << 11 << 12 << 13);
QTest::newRow("quaternion Rotation, offset = 10")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
suffixes.clear();
expectedResults.clear();
@@ -1581,19 +1687,22 @@ private Q_SLOTS:
channel.channelComponents[3].name = QLatin1String("Rotation Y");
dataType = static_cast<int>(QVariant::Quaternion);
+ expectedChannelComponentCount = 4;
offset = 0;
suffixes = (QVector<char>() << 'W' << 'X' << 'Y' << 'Z');
expectedResults = (QVector<int>() << 1 << 0 << 3 << 2);
QTest::newRow("quaternion Rotation, offset = 0, randomized")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
expectedResults.clear();
offset = 10;
expectedResults = (QVector<int>() << 11 << 10 << 13 << 12);
QTest::newRow("quaternion Rotation, offset = 10, randomized")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
suffixes.clear();
expectedResults.clear();
@@ -1609,37 +1718,95 @@ private Q_SLOTS:
channel.channelComponents[2].name = QLatin1String("Color B");
dataType = static_cast<int>(QVariant::Color);
+ expectedChannelComponentCount = 3;
offset = 0;
suffixes = (QVector<char>() << 'R' << 'G' << 'B');
expectedResults = (QVector<int>() << 0 << 1 << 2);
QTest::newRow("QColor Color, offset = 0")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
expectedResults.clear();
offset = 10;
expectedResults = (QVector<int>() << 10 << 11 << 12);
QTest::newRow("QColor Color, offset = 10")
- << channel << dataType << offset << suffixes << expectedResults;
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
suffixes.clear();
expectedResults.clear();
}
+
+ // weights as list with and without offset
+ {
+ channel = Channel();
+ channel.name = QLatin1String("MorphWeights");
+ channel.channelComponents.resize(6);
+ // leave channel component names empty
+
+ dataType = static_cast<int>(QVariant::List);
+ expectedChannelComponentCount = 6;
+ offset = 0;
+ // suffixes expected to be ignored
+ expectedResults = (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5);
+
+ QTest::newRow("MorphWeights List count = 6, offset = 0")
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
+ expectedResults.clear();
+
+ offset = 10;
+ expectedResults = (QVector<int>() << 10 << 11 << 12 << 13 << 14 << 15);
+ QTest::newRow("MorphWeights List count = 6, offset = 10")
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
+ suffixes.clear();
+ expectedResults.clear();
+ }
+
+ // weights as vec of float with and without offset
+ {
+ channel = Channel();
+ channel.name = QLatin1String("MorphWeights");
+ channel.channelComponents.resize(6);
+ // leave channel component names empty
+
+ dataType = qMetaTypeId<QVector<float>>();
+ expectedChannelComponentCount = 6;
+ offset = 0;
+ // suffixes expected to be ignored
+ expectedResults = (QVector<int>() << 0 << 1 << 2 << 3 << 4 << 5);
+
+ QTest::newRow("MorphWeights Vec count = 6, offset = 0")
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
+ expectedResults.clear();
+
+ offset = 10;
+ expectedResults = (QVector<int>() << 10 << 11 << 12 << 13 << 14 << 15);
+ QTest::newRow("MorphWeights Vec count = 6, offset = 10")
+ << channel << dataType << expectedChannelComponentCount
+ << offset << suffixes << expectedResults;
+ suffixes.clear();
+ expectedResults.clear();
+ }
}
void checkChannelComponentsToIndicesHelper()
{
// GIVEN
QFETCH(Channel, channel);
- QFETCH(int, dataType);
QFETCH(int, offset);
+ QFETCH(int, expectedChannelComponentCount);
QFETCH(QVector<char>, suffixes);
QFETCH(QVector<int>, expectedResults);
// WHEN
QVector<int> actualResults
- = channelComponentsToIndicesHelper(channel, dataType, offset, suffixes);
+ = channelComponentsToIndicesHelper(channel, expectedChannelComponentCount,
+ offset, suffixes);
// THEN
QCOMPARE(actualResults.size(), expectedResults.size());
@@ -1652,11 +1819,13 @@ private Q_SLOTS:
{
QTest::addColumn<Channel>("channel");
QTest::addColumn<int>("dataType");
+ QTest::addColumn<int>("componentCount");
QTest::addColumn<int>("offset");
QTest::addColumn<QVector<int>>("expectedResults");
Channel channel;
int dataType;
+ int componentCount;
int offset;
QVector<int> expectedResults;
@@ -1671,18 +1840,19 @@ private Q_SLOTS:
channel.channelComponents[3].name = QLatin1String("Rotation Z");
dataType = static_cast<int>(QVariant::Quaternion);
+ componentCount = 4;
offset = 0;
expectedResults = (QVector<int>() << 0 << 1 << 2 << 3);
QTest::newRow("quaternion Rotation, offset = 0")
- << channel << dataType << offset << expectedResults;
+ << channel << dataType << componentCount << offset << expectedResults;
expectedResults.clear();
offset = 10;
expectedResults = (QVector<int>() << 10 << 11 << 12 << 13);
QTest::newRow("quaternion Rotation, offset = 10")
- << channel << dataType << offset << expectedResults;
+ << channel << dataType << componentCount << offset << expectedResults;
expectedResults.clear();
}
@@ -1697,18 +1867,19 @@ private Q_SLOTS:
channel.channelComponents[2].name = QLatin1String("Location Z");
dataType = static_cast<int>(QVariant::Vector3D);
+ componentCount = 3;
offset = 0;
expectedResults = (QVector<int>() << 0 << 1 << 2);
QTest::newRow("vec3 location, offset = 0")
- << channel << dataType << offset << expectedResults;
+ << channel << dataType << componentCount << offset << expectedResults;
expectedResults.clear();
offset = 4;
expectedResults = (QVector<int>() << 4 << 5 << 6);
QTest::newRow("vec3 location, offset = 4")
- << channel << dataType << offset << expectedResults;
+ << channel << dataType << componentCount << offset << expectedResults;
expectedResults.clear();
}
@@ -1723,18 +1894,19 @@ private Q_SLOTS:
channel.channelComponents[2].name = QLatin1String("Color B");
dataType = static_cast<int>(QVariant::Color);
+ componentCount = 3;
offset = 0;
expectedResults = (QVector<int>() << 0 << 1 << 2);
QTest::newRow("QColor Color, offset = 0")
- << channel << dataType << offset << expectedResults;
+ << channel << dataType << componentCount << offset << expectedResults;
expectedResults.clear();
offset = 10;
expectedResults = (QVector<int>() << 10 << 11 << 12);
QTest::newRow("QColor Color, offset = 10")
- << channel << dataType << offset << expectedResults;
+ << channel << dataType << componentCount << offset << expectedResults;
expectedResults.clear();
}
@@ -1744,12 +1916,13 @@ private Q_SLOTS:
{
QFETCH(Channel, channel);
QFETCH(int, dataType);
+ QFETCH(int, componentCount);
QFETCH(int, offset);
QFETCH(QVector<int>, expectedResults);
// WHEN
QVector<int> actualResults
- = channelComponentsToIndices(channel, dataType, offset);
+ = channelComponentsToIndices(channel, dataType, componentCount, offset);
// THEN
QCOMPARE(actualResults.size(), expectedResults.size());
@@ -2387,7 +2560,8 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
QVector<ChannelMapping *> channelMappings;
channelMappings.push_back(channelMapping);
@@ -2397,6 +2571,7 @@ private Q_SLOTS:
QVector<ChannelNameAndType> expectedResults;
expectedResults.push_back({ QLatin1String("Location"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping->peerId() });
QTest::addRow("Location, vec3") << handler << channelMapper << expectedResults;
@@ -2409,13 +2584,15 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
auto channelMapping2 = createChannelMapping(handler,
QLatin1String("Rotation"),
Qt3DCore::QNodeId::createId(),
QLatin1String("rotatrion"),
"rotation",
- static_cast<int>(QVariant::Quaternion));
+ static_cast<int>(QVariant::Quaternion),
+ 4);
QVector<ChannelMapping *> channelMappings;
channelMappings.push_back(channelMapping1);
channelMappings.push_back(channelMapping2);
@@ -2429,9 +2606,11 @@ private Q_SLOTS:
QVector<ChannelNameAndType> expectedResults;
expectedResults.push_back({ QLatin1String("Location"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping1->peerId() });
expectedResults.push_back({ QLatin1String("Rotation"),
static_cast<int>(QVariant::Quaternion),
+ 4,
channelMapping2->peerId() });
QTest::addRow("Multiple unique channels") << handler << channelMapper << expectedResults;
@@ -2444,25 +2623,29 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
auto channelMapping2 = createChannelMapping(handler,
QLatin1String("Rotation"),
Qt3DCore::QNodeId::createId(),
QLatin1String("rotation"),
"rotation",
- static_cast<int>(QVariant::Quaternion));
+ static_cast<int>(QVariant::Quaternion),
+ 4);
auto channelMapping3 = createChannelMapping(handler,
QLatin1String("Location"),
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
auto channelMapping4 = createChannelMapping(handler,
QLatin1String("Location"),
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
QVector<ChannelMapping *> channelMappings;
channelMappings.push_back(channelMapping1);
@@ -2481,15 +2664,19 @@ private Q_SLOTS:
QVector<ChannelNameAndType> expectedResults;
expectedResults.push_back({ QLatin1String("Location"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping1->peerId() });
expectedResults.push_back({ QLatin1String("Rotation"),
static_cast<int>(QVariant::Quaternion),
+ 4,
channelMapping2->peerId() });
expectedResults.push_back({ QLatin1String("Location"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping3->peerId() });
expectedResults.push_back({ QLatin1String("Location"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping4->peerId() });
QTest::addRow("Multiple channels with repeats") << handler << channelMapper << expectedResults;
@@ -2510,6 +2697,7 @@ private Q_SLOTS:
for (int i = 0; i < jointCount; ++i) {
ChannelNameAndType locationDescription = { QLatin1String("Location"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping->peerId() };
locationDescription.jointIndex = i;
locationDescription.jointTransformComponent = Translation;
@@ -2517,6 +2705,7 @@ private Q_SLOTS:
ChannelNameAndType rotationDescription = { QLatin1String("Rotation"),
static_cast<int>(QVariant::Quaternion),
+ 4,
channelMapping->peerId() };
rotationDescription.jointIndex = i;
rotationDescription.jointTransformComponent = Rotation;
@@ -2524,6 +2713,7 @@ private Q_SLOTS:
ChannelNameAndType scaleDescription = { QLatin1String("Scale"),
static_cast<int>(QVariant::Vector3D),
+ 3,
channelMapping->peerId() };
scaleDescription.jointIndex = i;
scaleDescription.jointTransformComponent = Scale;
@@ -2560,7 +2750,7 @@ private Q_SLOTS:
{
QVector<ChannelNameAndType> allChannels;
- allChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
+ allChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D), 3 });
QVector<ComponentIndices> expectedResults;
expectedResults.push_back({ 0, 1, 2 });
@@ -2570,8 +2760,8 @@ private Q_SLOTS:
{
QVector<ChannelNameAndType> allChannels;
- allChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
- allChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) });
+ allChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D), 3 });
+ allChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion), 4 });
QVector<ComponentIndices> expectedResults;
expectedResults.push_back({ 0, 1, 2 });
@@ -2582,11 +2772,12 @@ private Q_SLOTS:
{
QVector<ChannelNameAndType> allChannels;
- allChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
- allChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) });
- allChannels.push_back({ QLatin1String("BaseColor"), static_cast<int>(QVariant::Vector3D) });
- allChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) });
- allChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) });
+ allChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D), 3 });
+ allChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion), 4 });
+ allChannels.push_back({ QLatin1String("BaseColor"), static_cast<int>(QVariant::Vector3D), 3 });
+ allChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double), 1 });
+ allChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double), 1 });
+ allChannels.push_back({ QLatin1String("MorphWeights"), static_cast<int>(QVariant::List), 6 });
QVector<ComponentIndices> expectedResults;
expectedResults.push_back({ 0, 1, 2 });
@@ -2594,23 +2785,24 @@ private Q_SLOTS:
expectedResults.push_back({ 7, 8, 9 });
expectedResults.push_back({ 10 });
expectedResults.push_back({ 11 });
+ expectedResults.push_back({ 12, 13, 14, 15, 16, 17 });
- QTest::newRow("vec3 location, quaterion rotation, pbr metal-rough") << allChannels << expectedResults;
+ QTest::newRow("vec3 location, quaterion rotation, pbr metal-rough morphweights") << allChannels << expectedResults;
}
{
QVector<ChannelNameAndType> allChannels;
const int jointCount = 4;
for (int i = 0; i < jointCount; ++i) {
- ChannelNameAndType locationDescription = { QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) };
+ ChannelNameAndType locationDescription = { QLatin1String("Location"), static_cast<int>(QVariant::Vector3D), 3 };
locationDescription.jointIndex = i;
allChannels.push_back(locationDescription);
- ChannelNameAndType rotationDescription = { QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) };
+ ChannelNameAndType rotationDescription = { QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion), 4 };
rotationDescription.jointIndex = i;
allChannels.push_back(rotationDescription);
- ChannelNameAndType scaleDescription = { QLatin1String("Scale"), static_cast<int>(QVariant::Vector3D) };
+ ChannelNameAndType scaleDescription = { QLatin1String("Scale"), static_cast<int>(QVariant::Vector3D), 3 };
scaleDescription.jointIndex = i;
allChannels.push_back(scaleDescription);
}
@@ -2665,11 +2857,11 @@ private Q_SLOTS:
{
QVector<ChannelNameAndType> targetChannels;
- targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) });
- targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
- targetChannels.push_back({ QLatin1String("Base Color"), static_cast<int>(QVariant::Vector3D) });
- targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) });
- targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) });
+ targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion), 4 });
+ targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D), 3 });
+ targetChannels.push_back({ QLatin1String("Base Color"), static_cast<int>(QVariant::Vector3D), 3 });
+ targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double), 1 });
+ targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double), 1 });
QVector<ComponentIndices> targetIndices;
targetIndices.push_back({ 0, 1, 2, 3 });
@@ -2703,11 +2895,11 @@ private Q_SLOTS:
{
QVector<ChannelNameAndType> targetChannels;
- targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
- targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) });
- targetChannels.push_back({ QLatin1String("Base Color"), static_cast<int>(QVariant::Vector3D) });
- targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) });
- targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) });
+ targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D), 3 });
+ targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion), 4 });
+ targetChannels.push_back({ QLatin1String("Base Color"), static_cast<int>(QVariant::Vector3D), 3 });
+ targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double), 1 });
+ targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double), 1 });
QVector<ComponentIndices> targetIndices;
targetIndices.push_back({ 0, 1, 2 });
@@ -2741,11 +2933,11 @@ private Q_SLOTS:
{
QVector<ChannelNameAndType> targetChannels;
- targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) });
- targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
- targetChannels.push_back({ QLatin1String("Albedo"), static_cast<int>(QVariant::Vector3D) });
- targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) });
- targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) });
+ targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion), 4 });
+ targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D), 3 });
+ targetChannels.push_back({ QLatin1String("Albedo"), static_cast<int>(QVariant::Vector3D), 3 });
+ targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double), 1 });
+ targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double), 1 });
QVector<ComponentIndices> targetIndices;
targetIndices.push_back({ 0, 1, 2, 3 });
@@ -2779,11 +2971,11 @@ private Q_SLOTS:
{
QVector<ChannelNameAndType> targetChannels;
- targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) });
- targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) });
- targetChannels.push_back({ QLatin1String("Albedo"), static_cast<int>(QVariant::Vector3D) });
- targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double) });
- targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double) });
+ targetChannels.push_back({ QLatin1String("Location"), static_cast<int>(QVariant::Vector3D), 3 });
+ targetChannels.push_back({ QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion), 4 });
+ targetChannels.push_back({ QLatin1String("Albedo"), static_cast<int>(QVariant::Vector3D), 3 });
+ targetChannels.push_back({ QLatin1String("Metalness"), static_cast<int>(QVariant::Double), 1 });
+ targetChannels.push_back({ QLatin1String("Roughness"), static_cast<int>(QVariant::Double), 1 });
QVector<ComponentIndices> targetIndices;
targetIndices.push_back({ 0, 1, 2 });
@@ -2819,15 +3011,15 @@ private Q_SLOTS:
QVector<ChannelNameAndType> targetChannels;
const int jointCount = 4;
for (int i = 0; i < jointCount; ++i) {
- ChannelNameAndType locationDescription = { QLatin1String("Location"), static_cast<int>(QVariant::Vector3D) };
+ ChannelNameAndType locationDescription = { QLatin1String("Location"), static_cast<int>(QVariant::Vector3D), 3 };
locationDescription.jointIndex = i;
targetChannels.push_back(locationDescription);
- ChannelNameAndType rotationDescription = { QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion) };
+ ChannelNameAndType rotationDescription = { QLatin1String("Rotation"), static_cast<int>(QVariant::Quaternion), 4 };
rotationDescription.jointIndex = i;
targetChannels.push_back(rotationDescription);
- ChannelNameAndType scaleDescription = { QLatin1String("Scale"), static_cast<int>(QVariant::Vector3D) };
+ ChannelNameAndType scaleDescription = { QLatin1String("Scale"), static_cast<int>(QVariant::Vector3D), 3 };
scaleDescription.jointIndex = i;
targetChannels.push_back(scaleDescription);
}
@@ -2934,7 +3126,8 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
ChannelNameAndType channelDescription;
channelDescription.mappingId = channelMapping->peerId();
channelDescription.type = static_cast<int>(QVariant::Vector3D);
@@ -2950,7 +3143,8 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("rotation"),
"rotation",
- static_cast<int>(QVariant::Quaternion));
+ static_cast<int>(QVariant::Quaternion),
+ 4);
ChannelNameAndType channelDescription;
channelDescription.mappingId = channelMapping->peerId();
channelDescription.type = static_cast<int>(QVariant::Quaternion);
@@ -2966,7 +3160,8 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("scale"),
"scale",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
ChannelNameAndType channelDescription;
channelDescription.mappingId = channelMapping->peerId();
channelDescription.type = static_cast<int>(QVariant::Vector3D);
diff --git a/tests/auto/animation/channelmapping/tst_channelmapping.cpp b/tests/auto/animation/channelmapping/tst_channelmapping.cpp
index a947d4a2d..5c04c7f89 100644
--- a/tests/auto/animation/channelmapping/tst_channelmapping.cpp
+++ b/tests/auto/animation/channelmapping/tst_channelmapping.cpp
@@ -41,6 +41,18 @@
#include <Qt3DCore/private/qbackendnode_p.h>
#include "testpostmanarbiter.h"
+class tst_TargetEntity : public Qt3DCore::QEntity
+{
+ Q_OBJECT
+ Q_PROPERTY(QVector2D foo MEMBER m_foo NOTIFY fooChanged)
+
+signals:
+ void fooChanged();
+
+private:
+ QVector2D m_foo;
+};
+
class tst_ChannelMapping : public Qt3DCore::QBackendNodeTester
{
Q_OBJECT
@@ -53,7 +65,7 @@ private Q_SLOTS:
Qt3DAnimation::Animation::ChannelMapping backendMapping;
backendMapping.setHandler(&handler);
Qt3DAnimation::QChannelMapping mapping;
- auto target = new Qt3DCore::QEntity;
+ auto target = new tst_TargetEntity;
mapping.setChannelName(QLatin1String("Location"));
mapping.setTarget(target);
@@ -68,6 +80,9 @@ private Q_SLOTS:
QCOMPARE(backendMapping.channelName(), mapping.channelName());
QCOMPARE(backendMapping.targetId(), mapping.target()->id());
QCOMPARE(backendMapping.property(), mapping.property());
+ QVERIFY(qstrcmp(backendMapping.propertyName(), "foo") == 0);
+ QCOMPARE(backendMapping.componentCount(), 2);
+ QCOMPARE(backendMapping.type(), static_cast<int>(QVariant::Vector2D));
QCOMPARE(backendMapping.mappingType(), Qt3DAnimation::Animation::ChannelMapping::ChannelMappingType);
// GIVEN
@@ -100,12 +115,15 @@ private Q_SLOTS:
QCOMPARE(backendMapping.channelName(), QString());
QCOMPARE(backendMapping.targetId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.property(), QString());
+ QCOMPARE(backendMapping.propertyName(), nullptr);
+ QCOMPARE(backendMapping.componentCount(), 0);
+ QCOMPARE(backendMapping.type(), static_cast<int>(QVariant::Invalid));
QCOMPARE(backendMapping.skeletonId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.mappingType(), Qt3DAnimation::Animation::ChannelMapping::ChannelMappingType);
// GIVEN
Qt3DAnimation::QChannelMapping mapping;
- auto target = new Qt3DCore::QEntity;
+ auto target = new tst_TargetEntity;
mapping.setChannelName(QLatin1String("Location"));
mapping.setTarget(target);
mapping.setProperty(QLatin1String("foo"));
@@ -120,6 +138,9 @@ private Q_SLOTS:
QCOMPARE(backendMapping.channelName(), QString());
QCOMPARE(backendMapping.targetId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.property(), QString());
+ QCOMPARE(backendMapping.propertyName(), nullptr);
+ QCOMPARE(backendMapping.componentCount(), 0);
+ QCOMPARE(backendMapping.type(), static_cast<int>(QVariant::Invalid));
QCOMPARE(backendMapping.skeletonId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.mappingType(), Qt3DAnimation::Animation::ChannelMapping::ChannelMappingType);
}
@@ -172,6 +193,34 @@ private Q_SLOTS:
QCOMPARE(backendMapping.property(), property);
// WHEN
+ updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId());
+ updateChange->setPropertyName("type");
+ updateChange->setValue(QVariant(static_cast<int>(QVariant::Vector3D)));
+ backendMapping.sceneChangeEvent(updateChange);
+
+ // THEN
+ QCOMPARE(backendMapping.type(), static_cast<int>(QVariant::Vector3D));
+
+ // WHEN
+ updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId());
+ updateChange->setPropertyName("componentCount");
+ updateChange->setValue(4);
+ backendMapping.sceneChangeEvent(updateChange);
+
+ // THEN
+ QCOMPARE(backendMapping.componentCount(), 4);
+
+ // WHEN
+ const char *testName = "883";
+ updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId());
+ updateChange->setPropertyName("propertyName");
+ updateChange->setValue(QVariant::fromValue(reinterpret_cast<void *>(const_cast<char *>(testName))));
+ backendMapping.sceneChangeEvent(updateChange);
+
+ // THEN
+ QCOMPARE(backendMapping.propertyName(), testName);
+
+ // WHEN
const auto skeletonId = Qt3DCore::QNodeId::createId();
updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId());
updateChange->setPropertyName("skeleton");
diff --git a/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp b/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp
index 50c0eb524..cc09c7941 100644
--- a/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp
+++ b/tests/auto/animation/findrunningclipanimatorsjob/tst_findrunningclipanimatorsjob.cpp
@@ -61,7 +61,8 @@ public:
const Qt3DCore::QNodeId targetId,
const QString &property,
const char *propertyName,
- int type)
+ int type,
+ int componentCount)
{
auto channelMappingId = Qt3DCore::QNodeId::createId();
ChannelMapping *channelMapping = handler->channelMappingManager()->getOrCreateResource(channelMappingId);
@@ -72,6 +73,7 @@ public:
channelMapping->setPropertyName(propertyName);
channelMapping->setChannelName(channelName);
channelMapping->setType(type);
+ channelMapping->setComponentCount(componentCount);
channelMapping->setMappingType(ChannelMapping::ChannelMappingType);
return channelMapping;
}
@@ -143,7 +145,8 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
QVector<ChannelMapping *> channelMappings;
channelMappings.push_back(channelMapping);
@@ -188,7 +191,8 @@ private Q_SLOTS:
Qt3DCore::QNodeId::createId(),
QLatin1String("translation"),
"translation",
- static_cast<int>(QVariant::Vector3D));
+ static_cast<int>(QVariant::Vector3D),
+ 3);
QVector<ChannelMapping *> channelMappings;
channelMappings.push_back(channelMapping);
@@ -198,9 +202,9 @@ private Q_SLOTS:
animator->setEnabled(false); // Has to be marked as enabled for the job to process it
QTest::newRow("disabled animator")
- << handler
- << dirtyClipAnimators
- << expectedResults;
+ << handler
+ << dirtyClipAnimators
+ << expectedResults;
}
}
diff --git a/tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp b/tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp
index cab5fda6f..091876d09 100644
--- a/tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp
+++ b/tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp
@@ -28,6 +28,7 @@
#include <QtTest/QTest>
#include <Qt3DAnimation/qchannelmapping.h>
+#include <Qt3DAnimation/private/qabstractchannelmapping_p.h>
#include <Qt3DAnimation/private/qchannelmapping_p.h>
#include <Qt3DAnimation/private/qchannelmappingcreatedchange_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
@@ -36,8 +37,49 @@
#include <Qt3DCore/private/qnodecreatedchangegenerator_p.h>
#include <QObject>
#include <QSignalSpy>
+#include <QQuaternion>
#include <testpostmanarbiter.h>
+class tst_QTargetEntity : public Qt3DCore::QEntity
+{
+ Q_OBJECT
+ Q_PROPERTY(QQuaternion rotation MEMBER m_rotation NOTIFY rotationChanged)
+ Q_PROPERTY(QVector3D translation MEMBER m_translation NOTIFY translationChanged)
+ Q_PROPERTY(QVector3D scale MEMBER m_scale NOTIFY scaleChanged)
+ Q_PROPERTY(float floatProperty MEMBER m_floatProperty NOTIFY floatPropertyChanged)
+ Q_PROPERTY(QVector2D vec2Property MEMBER m_vec2Property NOTIFY vec2PropertyChanged)
+ Q_PROPERTY(QVector3D vec3Property MEMBER m_vec3Property NOTIFY vec3PropertyChanged)
+ Q_PROPERTY(QVector4D vec4Property MEMBER m_vec4Property NOTIFY vec4PropertyChanged)
+ Q_PROPERTY(QQuaternion quaternionProperty MEMBER m_quaternionProperty NOTIFY quaternionPropertyChanged)
+ Q_PROPERTY(QVariantList listProperty MEMBER m_listProperty NOTIFY listPropertyChanged)
+ Q_PROPERTY(QVector<float> vecProperty MEMBER m_vecProperty NOTIFY vecPropertyChanged)
+
+signals:
+ void rotationChanged();
+ void translationChanged();
+ void scaleChanged();
+ void floatPropertyChanged();
+ void vec2PropertyChanged();
+ void vec3PropertyChanged();
+ void vec4PropertyChanged();
+ void quaternionPropertyChanged();
+ void listPropertyChanged();
+ void vecPropertyChanged();
+
+private:
+ QQuaternion m_rotation;
+ QVector3D m_translation;
+ QVector3D m_scale;
+ float m_floatProperty;
+ QVector2D m_vec2Property;
+ QVector3D m_vec3Property;
+ QVector4D m_vec4Property;
+ QQuaternion m_quaternionProperty;
+ QVariantList m_listProperty;
+ QVector<float> m_vecProperty;
+};
+
+
class tst_QChannelMapping : public QObject
{
Q_OBJECT
@@ -52,6 +94,13 @@ private Q_SLOTS:
QCOMPARE(mapping.channelName(), QString());
QCOMPARE(mapping.target(), static_cast<Qt3DCore::QNode *>(nullptr));
QCOMPARE(mapping.property(), QString());
+
+ const Qt3DAnimation::QChannelMappingPrivate *d =
+ static_cast<const Qt3DAnimation::QChannelMappingPrivate *>(
+ Qt3DAnimation::QChannelMappingPrivate::get(&mapping));
+
+ QCOMPARE(d->m_type, static_cast<int>(QVariant::Invalid));
+ QCOMPARE(d->m_componentCount, 0);
}
void checkPropertyChanges()
@@ -125,7 +174,7 @@ private Q_SLOTS:
{
// GIVEN
Qt3DAnimation::QChannelMapping mapping;
- auto target = new Qt3DCore::QEntity;
+ auto target = new tst_QTargetEntity;
mapping.setChannelName(QStringLiteral("Location"));
mapping.setTarget(target);
@@ -154,6 +203,8 @@ private Q_SLOTS:
QCOMPARE(mapping.channelName(), data.channelName);
QCOMPARE(mapping.target()->id(), data.targetId);
QCOMPARE(mapping.property(), data.property);
+ QCOMPARE(data.type, static_cast<int>(QVariant::Vector3D));
+ QCOMPARE(data.componentCount, 3);
}
// WHEN
@@ -179,6 +230,8 @@ private Q_SLOTS:
QCOMPARE(mapping.channelName(), data.channelName);
QCOMPARE(mapping.target()->id(), data.targetId);
QCOMPARE(mapping.property(), data.property);
+ QCOMPARE(data.type, static_cast<int>(QVariant::Vector3D));
+ QCOMPARE(data.componentCount, 3);
}
}
@@ -187,6 +240,7 @@ private Q_SLOTS:
// GIVEN
TestArbiter arbiter;
Qt3DAnimation::QChannelMapping mapping;
+ QScopedPointer<Qt3DCore::QEntity> target(new tst_QTargetEntity());
arbiter.setArbiterOnNode(&mapping);
{
@@ -213,8 +267,7 @@ private Q_SLOTS:
{
// WHEN
- auto target = new Qt3DCore::QEntity();
- mapping.setTarget(target);
+ mapping.setTarget(target.data());
QCoreApplication::processEvents();
// THEN
@@ -227,7 +280,7 @@ private Q_SLOTS:
arbiter.events.clear();
// WHEN
- mapping.setTarget(target);
+ mapping.setTarget(target.data());
QCoreApplication::processEvents();
// THEN
@@ -236,16 +289,32 @@ private Q_SLOTS:
{
// WHEN
+ target->setProperty("scale", QVector3D(1.0f, 0.0f, 0.0f));
mapping.setProperty(QStringLiteral("scale"));
QCoreApplication::processEvents();
// THEN
- QCOMPARE(arbiter.events.size(), 1);
- auto change = arbiter.events.first().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(arbiter.events.size(), 4);
+ auto change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
QCOMPARE(change->propertyName(), "property");
QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
QCOMPARE(change->value().toString(), mapping.property());
+ change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "type");
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QCOMPARE(change->value().toInt(), static_cast<int>(QVariant::Vector3D));
+
+ change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "componentCount");
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QCOMPARE(change->value().toInt(), 3);
+
+ change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "propertyName");
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QVERIFY(qstrcmp(reinterpret_cast<const char *>(change->value().value<void *>()), "scale") == 0);
+
arbiter.events.clear();
// WHEN
@@ -255,8 +324,88 @@ private Q_SLOTS:
// THEN
QCOMPARE(arbiter.events.size(), 0);
}
+ }
+ void checkPropertyUpdateNameTypeAndComponentCount_data()
+ {
+ QTest::addColumn<QByteArray>("propertyName");
+ QTest::addColumn<QVariant>("value");
+ QTest::addColumn<int>("expectedType");
+ QTest::addColumn<int>("expectedComponentCount");
+
+ QTest::newRow("float") << QByteArrayLiteral("floatProperty") << QVariant(1.0f) << static_cast<int>(QMetaType::Float) << 1;
+ QTest::newRow("vec2") << QByteArrayLiteral("vec2Property") << QVariant(QVector2D(1.0f, 1.0f)) << static_cast<int>(QVariant::Vector2D) << 2;
+ QTest::newRow("vec3") << QByteArrayLiteral("vec3Property") << QVariant(QVector3D(1.0f, 1.0f, 1.0f)) << static_cast<int>(QVariant::Vector3D) << 3;
+ QTest::newRow("vec4") << QByteArrayLiteral("vec4Property") << QVariant(QVector4D(1.0f, 1.0f, 1.0f, 1.0f)) << static_cast<int>(QVariant::Vector4D) << 4;
+ QTest::newRow("quaternion") << QByteArrayLiteral("quaternionProperty") << QVariant(QQuaternion(1.0f, 1.0f, 1.0f, 1.0f)) << static_cast<int>(QVariant::Quaternion) << 4;
+
+ QVariantList list = QVariantList() << QVariant(1.0f) << QVariant(1.0) << QVariant(1.0f) << QVariant(1.0f) << QVariant(1.0f);
+ QTest::newRow("variantlist") << QByteArrayLiteral("listProperty") << QVariant::fromValue(list) << static_cast<int>(QVariant::List) << 5;
+
+ QVector<float> vec(8);
+ QTest::newRow("vector") << QByteArrayLiteral("vecProperty") << QVariant::fromValue(vec) << qMetaTypeId<decltype(vec)>() << 8;
}
+
+ void checkPropertyUpdateNameTypeAndComponentCount()
+ {
+ // GIVEN
+ QFETCH(QByteArray, propertyName);
+ QFETCH(QVariant, value);
+ QFETCH(int, expectedType);
+ QFETCH(int, expectedComponentCount);
+
+ TestArbiter arbiter;
+ Qt3DAnimation::QChannelMapping mapping;
+ QScopedPointer<Qt3DCore::QEntity> target(new tst_QTargetEntity());
+ mapping.setTarget(target.data());
+ arbiter.setArbiterOnNode(&mapping);
+
+ {
+ // WHEN
+ target->setProperty(propertyName.constData(), value);
+ mapping.setProperty(QString::fromLatin1(propertyName));
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 5);
+
+ // Automatic notification change when property is updated
+ auto change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), propertyName.constData());
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QCOMPARE(change->value(), value);
+
+ change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "property");
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QCOMPARE(change->value().toString(), mapping.property());
+
+ change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "type");
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QCOMPARE(change->value().toInt(), expectedType);
+
+ change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "componentCount");
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QCOMPARE(change->value().toInt(), expectedComponentCount);
+
+ change = arbiter.events.takeFirst().staticCast<Qt3DCore::QPropertyUpdatedChange>();
+ QCOMPARE(change->propertyName(), "propertyName");
+ QCOMPARE(change->type(), Qt3DCore::PropertyUpdated);
+ QVERIFY(qstrcmp(reinterpret_cast<const char *>(change->value().value<void *>()), propertyName.constData()) == 0);
+
+ arbiter.events.clear();
+
+ // WHEN
+ mapping.setProperty(QString::fromLatin1(propertyName));
+ QCoreApplication::processEvents();
+
+ // THEN
+ QCOMPARE(arbiter.events.size(), 0);
+ }
+ }
+
};
QTEST_MAIN(tst_QChannelMapping)