diff options
author | Mike Krus <mike.krus@kdab.com> | 2019-10-01 22:59:52 +0100 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2019-10-08 12:48:13 +0100 |
commit | 7433513f5f08d02b9ed6233c4159f8f32f0db556 (patch) | |
tree | 0508fcebaf55981de53026bf954c366240aff098 /src/animation/backend/animationutils.cpp | |
parent | cae430b9ede8327217e5fa8e48b0de1f3d7cc364 (diff) |
Update animation evaluation jobs to use direct sync
Animation data is now stored in the job which propagates
them to the frontend at the end of the frame.
Animated properties are passed using Qt's property system.
Animated poses are passed via the frontend skeleton node.
Syncing on new frame will take care of propagating both for use in
other aspects.
Callbacks are called by the job directly or stored and invoked on
the main thread depending on the callback setting.
Change-Id: I78675715799300bc1b27f854f1a445c00a2ac734
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/animation/backend/animationutils.cpp')
-rw-r--r-- | src/animation/backend/animationutils.cpp | 53 |
1 files changed, 13 insertions, 40 deletions
diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index 24c484dc2..80c296a89 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -40,8 +40,6 @@ #include <Qt3DAnimation/private/clipblendnode_p.h> #include <Qt3DAnimation/private/clipblendnodevisitor_p.h> #include <Qt3DAnimation/private/clipblendvalue_p.h> -#include <Qt3DCore/qpropertyupdatedchange.h> -#include <Qt3DCore/private/qpropertyupdatedchangebase_p.h> #include <QtGui/qvector2d.h> #include <QtGui/qvector3d.h> #include <QtGui/qvector4d.h> @@ -407,13 +405,17 @@ QVariant buildPropertyValue(const MappingData &mappingData, const QVector<float> return QVariant(); } -QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId animatorId, - const QVector<MappingData> &mappingDataVec, - const QVector<float> &channelResults, - bool finalFrame, - float normalizedLocalTime) +AnimationRecord prepareAnimationRecord(Qt3DCore::QNodeId animatorId, + const QVector<MappingData> &mappingDataVec, + const QVector<float> &channelResults, + bool finalFrame, + float normalizedLocalTime) { - QVector<Qt3DCore::QSceneChangePtr> changes; + AnimationRecord record; + record.finalFrame = finalFrame; + record.animatorId = animatorId; + record.normalizedTime = normalizedLocalTime; + QVarLengthArray<Skeleton *, 4> dirtySkeletons; // Iterate over the mappings @@ -453,43 +455,14 @@ QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId anim break; } } else { - // TODOSYNC remove once we've found a way to propagate animation changes - // Construct a property update change, set target, property and delivery options - auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(mappingData.targetId); - e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll); - e->setPropertyName(mappingData.propertyName); - // Handle intermediate updates vs final flag properly - Qt3DCore::QPropertyUpdatedChangeBasePrivate::get(e.data())->m_isIntermediate = !finalFrame; - // Assign new value and send - e->setValue(v); - changes.push_back(e); + record.targetChanges.push_back({mappingData.targetId, mappingData.propertyName, v}); } } for (const auto skeleton : dirtySkeletons) - skeleton->sendLocalPoses(); - - if (isValidNormalizedTime(normalizedLocalTime)) { - // TODOSYNC remove once we've found a way to propagate animation changes - auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(animatorId); - e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll); - e->setPropertyName("normalizedTime"); - e->setValue(normalizedLocalTime); - Qt3DCore::QPropertyUpdatedChangeBasePrivate::get(e.data())->m_isIntermediate = !finalFrame; - changes.push_back(e); - } - - // If it's the final frame, notify the frontend that we've stopped - if (finalFrame) { - // TODOSYNC remove once we've found a way to propagate animation changes - auto e = Qt3DCore::QPropertyUpdatedChangePtr::create(animatorId); - e->setDeliveryFlags(Qt3DCore::QSceneChange::DeliverToAll); - e->setPropertyName("running"); - e->setValue(false); - changes.push_back(e); - } + record.skeletonChanges.push_back({skeleton->peerId(), skeleton->joints()}); - return changes; + return record; } QVector<AnimationCallbackAndValue> prepareCallbacks(const QVector<MappingData> &mappingDataVec, |