diff options
author | Sean Harmer <sean.harmer@kdab.com> | 2017-03-03 09:37:06 +0000 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2017-03-06 17:19:14 +0000 |
commit | 84f907017bb4fc72faf86bd70fbf49d629bc93f3 (patch) | |
tree | 4c0c93e0621ccdfe81e2b0486bacfc573240444c /src/animation/backend/animationutils_p.h | |
parent | f13d072a12d53e489f2647916a119878ea8208bb (diff) |
Remove AnimationUtils class
It was stateless, so make the static member functions free functions
and export them for auto tests. We're already in the
Qt3DAnimation::Animation namespace so this removes some visual clutter.
Change-Id: I4e1a72c47d5bd4afb807ce5f6dc80dc0ce4bb213
Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/animation/backend/animationutils_p.h')
-rw-r--r-- | src/animation/backend/animationutils_p.h | 141 |
1 files changed, 74 insertions, 67 deletions
diff --git a/src/animation/backend/animationutils_p.h b/src/animation/backend/animationutils_p.h index cb8014e7b..f66b3999d 100644 --- a/src/animation/backend/animationutils_p.h +++ b/src/animation/backend/animationutils_p.h @@ -62,81 +62,88 @@ class Handler; class AnimationClipLoader; class ChannelMapper; -class Q_AUTOTEST_EXPORT AnimationUtils +struct MappingData { -public: - struct MappingData - { - Qt3DCore::QNodeId targetId; - const char *propertyName; - int type; - QVector<int> channelIndices; - }; - - struct BlendingMappingData : public MappingData - { - QVector<int> channelIndicesClip1; - QVector<int> channelIndicesClip2; + Qt3DCore::QNodeId targetId; + const char *propertyName; + int type; + QVector<int> channelIndices; +}; - enum BlendAction { - NoBlending, // Use the channel from Clip1 only - ClipBlending, // Blending 2 clips sharing the same channel - }; - BlendAction blendAction; - }; +struct BlendingMappingData : public MappingData +{ + QVector<int> channelIndicesClip1; + QVector<int> channelIndicesClip2; - struct AnimatorEvaluationData - { - double globalTime; - double startTime; - int loopCount; - double playbackRate; + enum BlendAction { + NoBlending, // Use the channel from Clip1 only + ClipBlending, // Blending 2 clips sharing the same channel }; + BlendAction blendAction; +}; - struct ClipPreEvaluationData - { - int currentLoop; - double localTime; - bool isFinalFrame; - }; +struct AnimatorEvaluationData +{ + double globalTime; + double startTime; + int loopCount; + double playbackRate; +}; - template<typename Animator> - static AnimatorEvaluationData animatorEvaluationDataForAnimator(Animator animator, qint64 globalTime) - { - AnimationUtils::AnimatorEvaluationData data; - data.loopCount = animator->loops(); - data.playbackRate = 1.0; // should be a property on the animator - // Convert global time from nsec to sec - data.startTime = double(animator->startTime()) / 1.0e9; - data.globalTime = double(globalTime) / 1.0e9; - return data; - } - - static ClipPreEvaluationData evaluationDataForClip(AnimationClipLoader *clip, const AnimatorEvaluationData &animatorData); - - static QVector<int> channelComponentsToIndices(const Channel &channelGroup, - int dataType, - int offset = 0); - static QVector<int> channelComponentsToIndicesHelper(const Channel &channelGroup, - int dataType, - int offset, - const QStringList &suffixes); - static QVector<float> evaluateClipAtLocalTime(AnimationClipLoader *clip, - float localTime); - static QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId peerId, - const QVector<MappingData> &mappingData, - const QVector<float> &channelResults, - bool finalFrame); - static QVector<MappingData> buildPropertyMappings(Handler *handler, - const AnimationClipLoader *clip, - const ChannelMapper *mapper); - -private: - static double localTimeFromGlobalTime(double t_global, double t_start_global, - double playbackRate, double duration, - int loopCount, int ¤tLoop); +struct ClipPreEvaluationData +{ + int currentLoop; + double localTime; + bool isFinalFrame; }; +template<typename Animator> +AnimatorEvaluationData animatorEvaluationDataForAnimator(Animator animator, qint64 globalTime) +{ + AnimatorEvaluationData data; + data.loopCount = animator->loops(); + data.playbackRate = 1.0; // should be a property on the animator + // Convert global time from nsec to sec + data.startTime = double(animator->startTime()) / 1.0e9; + data.globalTime = double(globalTime) / 1.0e9; + return data; +} + +Q_AUTOTEST_EXPORT +ClipPreEvaluationData evaluationDataForClip(AnimationClipLoader *clip, + const AnimatorEvaluationData &animatorData); + +Q_AUTOTEST_EXPORT +QVector<int> channelComponentsToIndices(const Channel &channelGroup, + int dataType, + int offset = 0); + +Q_AUTOTEST_EXPORT +QVector<int> channelComponentsToIndicesHelper(const Channel &channelGroup, + int dataType, + int offset, + const QStringList &suffixes); + +Q_AUTOTEST_EXPORT +QVector<float> evaluateClipAtLocalTime(AnimationClipLoader *clip, + float localTime); + +Q_AUTOTEST_EXPORT +QVector<Qt3DCore::QSceneChangePtr> preparePropertyChanges(Qt3DCore::QNodeId peerId, + const QVector<MappingData> &mappingData, + const QVector<float> &channelResults, + bool finalFrame); + +Q_AUTOTEST_EXPORT +QVector<MappingData> buildPropertyMappings(Handler *handler, + const AnimationClipLoader *clip, + const ChannelMapper *mapper); + +Q_AUTOTEST_EXPORT +double localTimeFromGlobalTime(double t_global, double t_start_global, + double playbackRate, double duration, + int loopCount, int ¤tLoop); + } // Animation } // Qt3DAnimation |