summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/animation/backend/channelmapping.cpp9
-rw-r--r--src/animation/backend/channelmapping_p.h9
-rw-r--r--src/animation/frontend/qskeletonmapping_p.h1
-rw-r--r--tests/auto/animation/channelmapping/tst_channelmapping.cpp30
4 files changed, 48 insertions, 1 deletions
diff --git a/src/animation/backend/channelmapping.cpp b/src/animation/backend/channelmapping.cpp
index 79abe11f5..bf5be8383 100644
--- a/src/animation/backend/channelmapping.cpp
+++ b/src/animation/backend/channelmapping.cpp
@@ -37,6 +37,7 @@
#include "channelmapping_p.h"
#include <Qt3DAnimation/qchannelmapping.h>
#include <Qt3DAnimation/private/qchannelmapping_p.h>
+#include <Qt3DAnimation/private/qskeletonmapping_p.h>
#include <Qt3DAnimation/private/animationlogging_p.h>
#include <Qt3DAnimation/private/qchannelmappingcreatedchange_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
@@ -55,6 +56,7 @@ ChannelMapping::ChannelMapping()
, m_propertyName(nullptr)
, m_callback(nullptr)
, m_callbackFlags(0)
+ , m_skeletonId()
{
}
@@ -76,7 +78,9 @@ void ChannelMapping::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePt
}
case QChannelMappingCreatedChangeBase::SkeletonMapping: {
- // TODO: Add support for QSkeletonChannelMapping
+ const auto typedChange = qSharedPointerCast<QChannelMappingCreatedChange<QSkeletonMappingData>>(change);
+ const auto &data = typedChange->data;
+ m_skeletonId = data.skeletonId;
break;
}
@@ -97,6 +101,7 @@ void ChannelMapping::cleanup()
m_propertyName = nullptr;
m_callback = nullptr;
m_callbackFlags = 0;
+ m_skeletonId = Qt3DCore::QNodeId();
}
void ChannelMapping::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
@@ -118,6 +123,8 @@ void ChannelMapping::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
m_callback = static_cast<QAnimationCallback *>(change->value().value<void *>());
else if (change->propertyName() == QByteArrayLiteral("callbackFlags"))
m_callbackFlags = QAnimationCallback::Flags(change->value().toInt());
+ else if (change->propertyName() == QByteArrayLiteral("skeleton"))
+ m_skeletonId = change->value().value<Qt3DCore::QNodeId>();
break;
}
diff --git a/src/animation/backend/channelmapping_p.h b/src/animation/backend/channelmapping_p.h
index f2dde0c74..1be89cc88 100644
--- a/src/animation/backend/channelmapping_p.h
+++ b/src/animation/backend/channelmapping_p.h
@@ -93,16 +93,25 @@ public:
void setCallbackFlags(QAnimationCallback::Flags flags) { m_callbackFlags = flags; }
QAnimationCallback::Flags callbackFlags() const { return m_callbackFlags; }
+ void setSkeletonId(Qt3DCore::QNodeId skeletonId) { m_skeletonId = skeletonId; }
+ Qt3DCore::QNodeId skeletonId() const { return m_skeletonId; }
+
private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_FINAL;
+ // Properties from QChannelMapping
QString m_channelName;
Qt3DCore::QNodeId m_targetId;
QString m_property;
int m_type;
const char *m_propertyName;
+
+ // TODO: Properties from QCallbackMapping
QAnimationCallback *m_callback;
QAnimationCallback::Flags m_callbackFlags;
+
+ // Properties from QSkeletonMapping
+ Qt3DCore::QNodeId m_skeletonId;
};
} // namespace Animation
diff --git a/src/animation/frontend/qskeletonmapping_p.h b/src/animation/frontend/qskeletonmapping_p.h
index 19f9c70ae..af8382b23 100644
--- a/src/animation/frontend/qskeletonmapping_p.h
+++ b/src/animation/frontend/qskeletonmapping_p.h
@@ -52,6 +52,7 @@
//
#include <Qt3DAnimation//private/qabstractchannelmapping_p.h>
+#include <Qt3DAnimation/qskeletonmapping.h>
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/animation/channelmapping/tst_channelmapping.cpp b/tests/auto/animation/channelmapping/tst_channelmapping.cpp
index 478406336..8f276f0bd 100644
--- a/tests/auto/animation/channelmapping/tst_channelmapping.cpp
+++ b/tests/auto/animation/channelmapping/tst_channelmapping.cpp
@@ -31,8 +31,10 @@
#include <Qt3DAnimation/private/handler_p.h>
#include <Qt3DAnimation/private/channelmapping_p.h>
#include <Qt3DAnimation/qchannelmapping.h>
+#include <Qt3DAnimation/qskeletonmapping.h>
#include <Qt3DAnimation/private/qchannelmapping_p.h>
#include <Qt3DCore/qentity.h>
+#include <Qt3DCore/qskeleton.h>
#include <Qt3DCore/private/qnode_p.h>
#include <Qt3DCore/private/qscene_p.h>
#include <Qt3DCore/qpropertyupdatedchange.h>
@@ -66,6 +68,21 @@ private Q_SLOTS:
QCOMPARE(backendMapping.channelName(), mapping.channelName());
QCOMPARE(backendMapping.targetId(), mapping.target()->id());
QCOMPARE(backendMapping.property(), mapping.property());
+
+ // GIVEN
+ Qt3DAnimation::Animation::ChannelMapping backendSkeletonMapping;
+ backendSkeletonMapping.setHandler(&handler);
+ Qt3DAnimation::QSkeletonMapping skeletonMapping;
+ auto skeleton = new Qt3DCore::QSkeleton;
+ skeletonMapping.setSkeleton(skeleton);
+
+ // WHEN
+ simulateInitialization(&skeletonMapping, &backendSkeletonMapping);
+
+ // THEN
+ QCOMPARE(backendSkeletonMapping.peerId(), skeletonMapping.id());
+ QCOMPARE(backendSkeletonMapping.isEnabled(), skeletonMapping.isEnabled());
+ QCOMPARE(backendSkeletonMapping.skeletonId(), skeletonMapping.skeleton()->id());
}
void checkInitialAndCleanedUpState()
@@ -81,6 +98,7 @@ private Q_SLOTS:
QCOMPARE(backendMapping.channelName(), QString());
QCOMPARE(backendMapping.targetId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.property(), QString());
+ QCOMPARE(backendMapping.skeletonId(), Qt3DCore::QNodeId());
// GIVEN
Qt3DAnimation::QChannelMapping mapping;
@@ -91,6 +109,7 @@ private Q_SLOTS:
// WHEN
simulateInitialization(&mapping, &backendMapping);
+ backendMapping.setSkeletonId(Qt3DCore::QNodeId::createId());
backendMapping.cleanup();
// THEN
@@ -98,6 +117,7 @@ private Q_SLOTS:
QCOMPARE(backendMapping.channelName(), QString());
QCOMPARE(backendMapping.targetId(), Qt3DCore::QNodeId());
QCOMPARE(backendMapping.property(), QString());
+ QCOMPARE(backendMapping.skeletonId(), Qt3DCore::QNodeId());
}
void checkPropertyChanges()
@@ -146,6 +166,16 @@ private Q_SLOTS:
// THEN
QCOMPARE(backendMapping.property(), property);
+
+ // WHEN
+ const auto skeletonId = Qt3DCore::QNodeId::createId();
+ updateChange = QSharedPointer<Qt3DCore::QPropertyUpdatedChange>::create(Qt3DCore::QNodeId());
+ updateChange->setPropertyName("skeleton");
+ updateChange->setValue(QVariant::fromValue(skeletonId));
+ backendMapping.sceneChangeEvent(updateChange);
+
+ // THEN
+ QCOMPARE(backendMapping.skeletonId(), skeletonId);
}
};