summaryrefslogtreecommitdiffstats
path: root/tests/auto/animation/animationutils/tst_animationutils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/animation/animationutils/tst_animationutils.cpp')
-rw-r--r--tests/auto/animation/animationutils/tst_animationutils.cpp367
1 files changed, 281 insertions, 86 deletions
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);