summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/animation/backend/clipanimator.cpp1
-rw-r--r--src/animation/backend/clipanimator_p.h4
-rw-r--r--src/animation/backend/evaluateclipanimatorjob.cpp8
-rw-r--r--src/animation/backend/findrunningclipanimatorsjob.cpp41
4 files changed, 39 insertions, 15 deletions
diff --git a/src/animation/backend/clipanimator.cpp b/src/animation/backend/clipanimator.cpp
index e68168f9e..92082b74f 100644
--- a/src/animation/backend/clipanimator.cpp
+++ b/src/animation/backend/clipanimator.cpp
@@ -104,6 +104,7 @@ void ClipAnimator::cleanup()
m_mapperId = Qt3DCore::QNodeId();
m_running = false;
m_loops = 1;
+ m_formatIndices.clear();
}
void ClipAnimator::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e)
diff --git a/src/animation/backend/clipanimator_p.h b/src/animation/backend/clipanimator_p.h
index 9db575ab9..5a9035dff 100644
--- a/src/animation/backend/clipanimator_p.h
+++ b/src/animation/backend/clipanimator_p.h
@@ -94,6 +94,9 @@ public:
void animationClipMarkedDirty() { setDirty(Handler::ClipAnimatorDirty); }
+ void setFormatIndices(const ComponentIndices &formatIndices) { m_formatIndices = formatIndices; }
+ ComponentIndices formatIndices() const { return m_formatIndices; }
+
private:
void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_FINAL;
@@ -107,6 +110,7 @@ private:
QVector<MappingData> m_mappingData;
int m_currentLoop;
+ ComponentIndices m_formatIndices;
};
} // namespace Animation
diff --git a/src/animation/backend/evaluateclipanimatorjob.cpp b/src/animation/backend/evaluateclipanimatorjob.cpp
index e89405d63..72e16a593 100644
--- a/src/animation/backend/evaluateclipanimatorjob.cpp
+++ b/src/animation/backend/evaluateclipanimatorjob.cpp
@@ -68,7 +68,11 @@ void EvaluateClipAnimatorJob::run()
// Prepare for evaluation (convert global time to local time ....)
const AnimatorEvaluationData animatorEvaluationData = evaluationDataForAnimator(clipAnimator, globalTime);
const ClipEvaluationData preEvaluationDataForClip = evaluationDataForClip(clip, animatorEvaluationData);
- const ClipResults channelResults = evaluateClipAtLocalTime(clip, preEvaluationDataForClip.localTime);
+ const ClipResults rawClipResults = evaluateClipAtLocalTime(clip, preEvaluationDataForClip.localTime);
+
+ // Reformat the clip results into the layout used by this animator/blend tree
+ ComponentIndices format = clipAnimator->formatIndices();
+ ClipResults formattedClipResults = formatClipResults(rawClipResults, format);
if (preEvaluationDataForClip.isFinalFrame)
clipAnimator->setRunning(false);
@@ -78,7 +82,7 @@ void EvaluateClipAnimatorJob::run()
// Prepare property changes (if finalFrame it also prepares the change for the running property for the frontend)
const QVector<Qt3DCore::QSceneChangePtr> changes = preparePropertyChanges(clipAnimator->peerId(),
clipAnimator->mappingData(),
- channelResults,
+ formattedClipResults,
preEvaluationDataForClip.isFinalFrame);
// Send the property changes
diff --git a/src/animation/backend/findrunningclipanimatorsjob.cpp b/src/animation/backend/findrunningclipanimatorsjob.cpp
index a8349eb91..41454004d 100644
--- a/src/animation/backend/findrunningclipanimatorsjob.cpp
+++ b/src/animation/backend/findrunningclipanimatorsjob.cpp
@@ -62,24 +62,39 @@ void FindRunningClipAnimatorsJob::run()
Q_ASSERT(m_handler);
ClipAnimatorManager *clipAnimatorManager = m_handler->clipAnimatorManager();
- for (const auto clipAnimatorHandle : qAsConst(m_clipAnimatorHandles)) {
+ for (const auto &clipAnimatorHandle : qAsConst(m_clipAnimatorHandles)) {
ClipAnimator *clipAnimator = clipAnimatorManager->data(clipAnimatorHandle);
Q_ASSERT(clipAnimator);
const bool canRun = clipAnimator->canRun();
m_handler->setClipAnimatorRunning(clipAnimatorHandle, canRun);
- // The clip animator needs to know how to map fcurve values through to
- // properties on QNodes. Now we know this animator can run, build the mapping
- // table.
- // TODO: Should be possible to parallelise this with the fcurve evaluation as
- // sending the property change events doesn't happen until after evaluation
- if (canRun) {
- const AnimationClip *clip = m_handler->animationClipLoaderManager()->lookupResource(clipAnimator->clipId());
- const ChannelMapper *mapper = m_handler->channelMapperManager()->lookupResource(clipAnimator->mapperId());
- Q_ASSERT(clip && mapper);
- const QVector<MappingData> mappingData = buildPropertyMappings(m_handler, clip, mapper);
- clipAnimator->setMappingData(mappingData);
- }
+ if (!canRun)
+ continue;
+
+ // The clip animator needs to know how to map fcurve values through to properties on QNodes.
+ // Now we know this animator can run, build the mapping table. Even though this could be
+ // done a little simpler in the non-blended case, we follow the same code path as the
+ // blended clip animator for consistency and ease of maintenance.
+ const ChannelMapper *mapper = m_handler->channelMapperManager()->lookupResource(clipAnimator->mapperId());
+ Q_ASSERT(mapper);
+ const QVector<ChannelMapping *> channelMappings = mapper->mappings();
+
+ const QVector<ChannelNameAndType> channelNamesAndTypes
+ = buildRequiredChannelsAndTypes(m_handler, mapper);
+ const QVector<ComponentIndices> channelComponentIndices
+ = assignChannelComponentIndices(channelNamesAndTypes);
+
+ const AnimationClip *clip = m_handler->animationClipLoaderManager()->lookupResource(clipAnimator->clipId());
+ Q_ASSERT(clip);
+ const ComponentIndices formatIndices = generateClipFormatIndices(channelNamesAndTypes,
+ channelComponentIndices,
+ clip);
+ clipAnimator->setFormatIndices(formatIndices);
+
+ const QVector<MappingData> mappingData = buildPropertyMappings(channelMappings,
+ channelNamesAndTypes,
+ channelComponentIndices);
+ clipAnimator->setMappingData(mappingData);
}
qCDebug(Jobs) << "Running clip animators =" << m_handler->runningClipAnimators();