From 75697d59cb6e3783bd1444816cfc90b4bc8b9aba Mon Sep 17 00:00:00 2001 From: Wieland Hagen Date: Fri, 15 Sep 2017 14:41:36 +0200 Subject: Clear TextureData flag after texture upload Or else we will continue uploading data indefinitely Change-Id: If81d8a0a790964c699462fbcb166808ee7859f59 Reviewed-by: Sean Harmer --- src/render/texture/gltexture.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/render/texture/gltexture.cpp b/src/render/texture/gltexture.cpp index 01159b78c..2571e99bd 100644 --- a/src/render/texture/gltexture.cpp +++ b/src/render/texture/gltexture.cpp @@ -203,6 +203,7 @@ QOpenGLTexture* GLTexture::getOrCreateGLTexture() // need to (re-)upload texture data? if (needUpload && !texturedDataInvalid) { uploadGLTextureData(); + setDirtyFlag(TextureData, false); } // need to set texture parameters? -- cgit v1.2.3 From ba9a38ceca15f9bc086a6c9c5d341001e9e73852 Mon Sep 17 00:00:00 2001 From: Wieland Hagen Date: Fri, 22 Sep 2017 12:21:09 +0200 Subject: Don't crash objgeometryloader on ill-formed face, just ignore For < 3 vertices, array accesses would fail, and face creation not make sense anyways Change-Id: I5eb746dfdec92d1c836e9870d87e7900530ec81c Reviewed-by: Sean Harmer --- src/plugins/geometryloaders/default/objgeometryloader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/geometryloaders/default/objgeometryloader.cpp b/src/plugins/geometryloaders/default/objgeometryloader.cpp index b1fb1f931..7184e2f69 100644 --- a/src/plugins/geometryloaders/default/objgeometryloader.cpp +++ b/src/plugins/geometryloaders/default/objgeometryloader.cpp @@ -144,7 +144,7 @@ bool ObjGeometryLoader::doLoad(QIODevice *ioDev, const QString &subMesh) ++normalsOffset; } } - } else if (!skipping && qstrncmp(tokens.charPtrAt(0), "f ", 2) == 0) { + } else if (!skipping && tokens.size() >= 4 && qstrncmp(tokens.charPtrAt(0), "f ", 2) == 0) { // Process face ++faceCount; -- cgit v1.2.3 From 72e80520d36802672eca1e93bc6c6019e6f5ffc3 Mon Sep 17 00:00:00 2001 From: Anders Hafreager Date: Sun, 24 Sep 2017 20:13:55 +0200 Subject: Copy size and pixelRatio when switching activeFrameGraph Copy externalRenderTargetSize and surfacePixelRatio from old to new surfaceSelector when setting activeFrameGraph on RenderSettings. Previously, when switching activeFrameGraph, surface was copied from old to new surfaceSelector, but these other properties were not. The rendered image was then stretched until window is resized again. Change-Id: I62b78da05c764f981813ab96b9a769bae7d786b2 Reviewed-by: Sean Harmer --- src/render/frontend/qrendersettings.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/render/frontend/qrendersettings.cpp b/src/render/frontend/qrendersettings.cpp index b73fed77b..e89764b4e 100644 --- a/src/render/frontend/qrendersettings.cpp +++ b/src/render/frontend/qrendersettings.cpp @@ -209,8 +209,11 @@ void QRenderSettings::setActiveFrameGraph(QFrameGraphNode *activeFrameGraph) if (d->m_activeFrameGraph && activeFrameGraph) { Qt3DRender::QRenderSurfaceSelector *oldSurfaceSelector = Qt3DRender::QRenderSurfaceSelectorPrivate::find(d->m_activeFrameGraph); Qt3DRender::QRenderSurfaceSelector *newSurfaceSelector = Qt3DRender::QRenderSurfaceSelectorPrivate::find(activeFrameGraph); - if (oldSurfaceSelector && newSurfaceSelector && oldSurfaceSelector->surface()) + if (oldSurfaceSelector && newSurfaceSelector && oldSurfaceSelector->surface()) { + newSurfaceSelector->setExternalRenderTargetSize(oldSurfaceSelector->externalRenderTargetSize()); + newSurfaceSelector->setSurfacePixelRatio(oldSurfaceSelector->surfacePixelRatio()); newSurfaceSelector->setSurface(oldSurfaceSelector->surface()); + } } if (d->m_activeFrameGraph) -- cgit v1.2.3 From 3aefe68f281f1815dcb6ca73751d17b470429a0f Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Thu, 31 Aug 2017 15:57:12 +0100 Subject: Fix gathering clip value node ids This correctly handles the case where the blend tree consists of a single value node. Added test case to catch it. Change-Id: I8982d2081748866d163f107a4513bd2d17feb83a Reviewed-by: Kevin Ottens --- src/animation/backend/animationutils.cpp | 4 ++++ src/animation/backend/clipblendvalue_p.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index c12ad99f7..1583a7fd7 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -467,6 +467,10 @@ QVector gatherValueNodesToEvaluate(Handler *handler, ClipBlendNodeVisitor::VisitOnlyDependencies); auto func = [&clipIds, nodeManager] (ClipBlendNode *blendNode) { + // Check if this is a value node itself + if (blendNode->blendType() == ClipBlendNode::ValueType) + clipIds.append(blendNode->peerId()); + const auto dependencyIds = blendNode->currentDependencyIds(); for (const auto dependencyId : dependencyIds) { // Look up the blend node and if it's a value type (clip), diff --git a/src/animation/backend/clipblendvalue_p.h b/src/animation/backend/clipblendvalue_p.h index 6da800f98..5ff8d2b0f 100644 --- a/src/animation/backend/clipblendvalue_p.h +++ b/src/animation/backend/clipblendvalue_p.h @@ -73,7 +73,7 @@ public: inline QVector currentDependencyIds() const Q_DECL_OVERRIDE { - return { m_clipId }; + return {}; } double duration() const Q_DECL_OVERRIDE; -- cgit v1.2.3 From a56240c13ea84f678085131e7ee52c2402361a07 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Fri, 22 Sep 2017 13:11:34 +0100 Subject: Avoid deep copy in loop Change-Id: I5a86547ae669394c290b30427f98821bc7552a63 Reviewed-by: Kevin Ottens --- src/animation/backend/animationutils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index 1583a7fd7..db49078cf 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -497,7 +497,7 @@ ComponentIndices generateClipFormatIndices(const QVector &ta // Reserve enough storage for all the format indices int indexCount = 0; - for (const auto targetIndexVec : qAsConst(targetIndices)) + for (const auto &targetIndexVec : qAsConst(targetIndices)) indexCount += targetIndexVec.size(); ComponentIndices format; format.resize(indexCount); -- cgit v1.2.3 From 8f2ced29ceedacd2f23f19af1813a5f351b43eec Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Fri, 22 Sep 2017 13:47:59 +0100 Subject: Actually get matching clip indices for components Rather than assuming they are in order. The blended clip animator code path now behaves the same as the simple QClipAnimator in that it can handle clips with channel components not in the expected order. We can now look at making both share a common code path. Change-Id: I61848e07b4f418ba9f4c56f56f4f49c9a5fbd588 Reviewed-by: Kevin Ottens --- src/animation/backend/animationutils.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index db49078cf..4d9fc4d30 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -502,7 +502,6 @@ ComponentIndices generateClipFormatIndices(const QVector &ta ComponentIndices format; format.resize(indexCount); - // Iterate through the target channels const int channelCount = targetChannels.size(); auto formatIt = format.begin(); @@ -510,18 +509,18 @@ ComponentIndices generateClipFormatIndices(const QVector &ta // Find the index of the channel from the clip const ChannelNameAndType &targetChannel = targetChannels[i]; const int clipChannelIndex = clip->channelIndex(targetChannel.name); - - // TODO: Ensure channel in the clip has enough components to map to the type. - // Requires some improvements to the clip data structure first. - // TODO: I don't think we need the targetIndices, only the number of components - // for each target channel. Check once blend tree is complete. const int componentCount = targetIndices[i].size(); if (clipChannelIndex != -1) { // Found a matching channel in the clip. Get the base channel // component index and populate the format indices for this channel. const int baseIndex = clip->channelComponentBaseIndex(clipChannelIndex); - std::iota(formatIt, formatIt + componentCount, baseIndex); + + // Within this group, match channel names with index ordering + const auto channelIndices = channelComponentsToIndices(clip->channels()[clipChannelIndex], + targetChannel.type, + baseIndex); + std::copy(channelIndices.begin(), channelIndices.end(), formatIt); } else { // No such channel in this clip. We'll use default values when -- cgit v1.2.3 From a286529cbe2ae51e6bf19aaea4203afd6b4884de Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Tue, 26 Sep 2017 11:10:27 +0100 Subject: Ensure meshName gets used in the functor Change-Id: I9015546607b5663f1feada64bc03cb73d3538ef2 Reviewed-by: Kevin Ottens --- src/render/geometry/qmesh.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/render/geometry/qmesh.cpp b/src/render/geometry/qmesh.cpp index 614806df0..cf14ff4ff 100644 --- a/src/render/geometry/qmesh.cpp +++ b/src/render/geometry/qmesh.cpp @@ -261,8 +261,10 @@ QGeometry *MeshFunctor::operator()() bool MeshFunctor::operator ==(const QGeometryFactory &other) const { const MeshFunctor *otherFunctor = functor_cast(&other); - if (otherFunctor != nullptr) - return (otherFunctor->m_sourcePath == m_sourcePath); + if (otherFunctor != nullptr) { + return (otherFunctor->m_sourcePath == m_sourcePath + && otherFunctor->m_meshName == m_meshName); + } return false; } -- cgit v1.2.3 From 78175fa89bc95b88466ecf1ac8b42244762e62e2 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Tue, 26 Sep 2017 15:21:50 +0100 Subject: Add convenience function to ChannelMapper to return list of Mappings Caches the resolution of node ids to ChannelMappings. Updated test to check this new feature. Change-Id: I0c2f539c2bd91e7918b98c5b60c9ca486b63ec08 Reviewed-by: Kevin Ottens --- src/animation/backend/channelmapper.cpp | 20 ++++++++++++++++++++ src/animation/backend/channelmapper_p.h | 12 ++++++++++++ 2 files changed, 32 insertions(+) (limited to 'src') diff --git a/src/animation/backend/channelmapper.cpp b/src/animation/backend/channelmapper.cpp index 0e5555096..48a1335fa 100644 --- a/src/animation/backend/channelmapper.cpp +++ b/src/animation/backend/channelmapper.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -50,6 +51,7 @@ namespace Animation { ChannelMapper::ChannelMapper() : BackendNode(ReadOnly) , m_mappingIds() + , m_isDirty(true) { } @@ -58,12 +60,15 @@ void ChannelMapper::initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr const auto typedChange = qSharedPointerCast>(change); const auto &data = typedChange->data; m_mappingIds = data.mappingIds; + m_isDirty = true; } void ChannelMapper::cleanup() { setEnabled(false); m_mappingIds.clear(); + m_mappings.clear(); + m_isDirty = true; } void ChannelMapper::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) @@ -74,6 +79,7 @@ void ChannelMapper::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) if (change->propertyName() == QByteArrayLiteral("mappings")) { m_mappingIds.push_back(change->addedNodeId()); setDirty(Handler::ChannelMappingsDirty); + m_isDirty = true; } break; } @@ -83,6 +89,7 @@ void ChannelMapper::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) if (change->propertyName() == QByteArrayLiteral("mappings")) { m_mappingIds.removeOne(change->removedNodeId()); setDirty(Handler::ChannelMappingsDirty); + m_isDirty = true; } break; } @@ -93,6 +100,19 @@ void ChannelMapper::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &e) QBackendNode::sceneChangeEvent(e); } +void ChannelMapper::updateMappings() const +{ + m_mappings.clear(); + m_mappings.reserve(m_mappingIds.size()); + const auto mappingManager = m_handler->channelMappingManager(); + for (const auto &mappingId : m_mappingIds) { + const auto mapping = mappingManager->lookupResource(mappingId); + Q_ASSERT(mapping); + m_mappings.push_back(mapping); + } + m_isDirty = false; +} + } // namespace Animation } // namespace Qt3DAnimation diff --git a/src/animation/backend/channelmapper_p.h b/src/animation/backend/channelmapper_p.h index 710de01ab..8d8f03511 100644 --- a/src/animation/backend/channelmapper_p.h +++ b/src/animation/backend/channelmapper_p.h @@ -74,10 +74,22 @@ public: void setMappingIds(const QVector &mappingIds) { m_mappingIds = mappingIds; } QVector mappingIds() const { return m_mappingIds; } + QVector mappings() const + { + if (m_isDirty) + updateMappings(); + return m_mappings; + } + private: void initializeFromPeer(const Qt3DCore::QNodeCreatedChangeBasePtr &change) Q_DECL_FINAL; + void updateMappings() const; QVector m_mappingIds; + + // Cached data + mutable QVector m_mappings; + mutable bool m_isDirty; }; } // namespace Animation -- cgit v1.2.3 From 9dfec23e472265911bff2a949a2536f68100b2ba Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Wed, 27 Sep 2017 16:45:43 +0100 Subject: Add unit test for FindRunningClipAnimatorsJob Should pass before and after the refactoring. Change-Id: I9ef8f948f03a131546fc6485e9c66494ff383714 Reviewed-by: Sean Harmer --- src/animation/backend/findrunningclipanimatorsjob_p.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/animation/backend/findrunningclipanimatorsjob_p.h b/src/animation/backend/findrunningclipanimatorsjob_p.h index 023f46303..f8b09939f 100644 --- a/src/animation/backend/findrunningclipanimatorsjob_p.h +++ b/src/animation/backend/findrunningclipanimatorsjob_p.h @@ -52,6 +52,10 @@ #include #include +#if defined(QT_BUILD_INTERNAL) +class tst_FindRunningClipAnimatorsJob; +#endif + QT_BEGIN_NAMESPACE namespace Qt3DAnimation { @@ -59,7 +63,7 @@ namespace Animation { class Handler; -class FindRunningClipAnimatorsJob : public Qt3DCore::QAspectJob +class Q_AUTOTEST_EXPORT FindRunningClipAnimatorsJob : public Qt3DCore::QAspectJob { public: FindRunningClipAnimatorsJob(); @@ -75,6 +79,10 @@ protected: private: QVector m_clipAnimatorHandles; Handler *m_handler; + +#if defined(QT_BUILD_INTERNAL) + friend class ::tst_FindRunningClipAnimatorsJob; +#endif }; } // namespace Animation -- cgit v1.2.3 From eee010020351c8aac94671dc6f34b17116f1f684 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Tue, 26 Sep 2017 15:25:12 +0100 Subject: Move the non-blended animation codepath closer to the blended one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Will make it possible to reduce the amount of code to maintain and test. There are still several ways to optimize this too so best to only do it for one code path that all animators use. Change-Id: I05ebd4f41d88aa0bea37d4d17130bc79c96ebd5c Reviewed-by: Sérgio Martins --- src/animation/backend/clipanimator.cpp | 1 + src/animation/backend/clipanimator_p.h | 4 +++ src/animation/backend/evaluateclipanimatorjob.cpp | 8 +++-- .../backend/findrunningclipanimatorsjob.cpp | 41 +++++++++++++++------- 4 files changed, 39 insertions(+), 15 deletions(-) (limited to 'src') 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 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 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 = 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 channelMappings = mapper->mappings(); + + const QVector channelNamesAndTypes + = buildRequiredChannelsAndTypes(m_handler, mapper); + const QVector 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 = buildPropertyMappings(channelMappings, + channelNamesAndTypes, + channelComponentIndices); + clipAnimator->setMappingData(mappingData); } qCDebug(Jobs) << "Running clip animators =" << m_handler->runningClipAnimators(); -- cgit v1.2.3 From aee10edf33ccb1faf3179b23b44a2ad48bf4d0f0 Mon Sep 17 00:00:00 2001 From: Sean Harmer Date: Wed, 27 Sep 2017 11:22:37 +0100 Subject: Remove unused buildPropertyMappings() overload and tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Everything goes through the other overload now. Change-Id: Id0c196a6967a9f83e47092ca1fc7f4ab4ebe9309 Reviewed-by: Sérgio Martins --- src/animation/backend/animationutils.cpp | 56 -------------------------------- src/animation/backend/animationutils_p.h | 5 --- 2 files changed, 61 deletions(-) (limited to 'src') diff --git a/src/animation/backend/animationutils.cpp b/src/animation/backend/animationutils.cpp index 4d9fc4d30..7051fd4d4 100644 --- a/src/animation/backend/animationutils.cpp +++ b/src/animation/backend/animationutils.cpp @@ -308,62 +308,6 @@ QVector preparePropertyChanges(Qt3DCore::QNodeId anim return changes; } -//TODO: Remove this and use new implementation below for both the unblended -// and blended animation cases. -QVector buildPropertyMappings(Handler *handler, - const AnimationClip *clip, - const ChannelMapper *mapper) -{ - QVector mappingDataVec; - ChannelMappingManager *mappingManager = handler->channelMappingManager(); - const QVector &channels = clip->channels(); - - // Iterate over the mappings in the mapper object - const auto mappingIds = mapper->mappingIds(); - for (const Qt3DCore::QNodeId mappingId : mappingIds) { - // Get the mapping object - ChannelMapping *mapping = mappingManager->lookupResource(mappingId); - Q_ASSERT(mapping); - - // Populate the data we need, easy stuff first - MappingData mappingData; - mappingData.targetId = mapping->targetId(); - mappingData.propertyName = mapping->propertyName(); - mappingData.type = mapping->type(); - - if (mappingData.type == static_cast(QVariant::Invalid)) { - qWarning() << "Unknown type for node id =" << mappingData.targetId - << "and property =" << mapping->property(); - continue; - } - - // Now the tricky part. Mapping the channel indices onto the property type. - // Try to find a ChannelGroup with matching name - const QString channelName = mapping->channelName(); - int channelGroupIndex = 0; - bool foundMatch = false; - for (const Channel &channel : channels) { - if (channel.name == channelName) { - foundMatch = true; - const int channelBaseIndex = clip->channelComponentBaseIndex(channelGroupIndex); - - // Within this group, match channel names with index ordering - mappingData.channelIndices = channelComponentsToIndices(channel, mappingData.type, channelBaseIndex); - - // Store the mapping data - mappingDataVec.push_back(mappingData); - - if (foundMatch) - break; - } - - ++channelGroupIndex; - } - } - - return mappingDataVec; -} - QVector buildPropertyMappings(const QVector &channelMappings, const QVector &channelNamesAndTypes, const QVector &channelComponentIndices) diff --git a/src/animation/backend/animationutils_p.h b/src/animation/backend/animationutils_p.h index f8fcbafa7..c702ab5c4 100644 --- a/src/animation/backend/animationutils_p.h +++ b/src/animation/backend/animationutils_p.h @@ -156,11 +156,6 @@ QVector preparePropertyChanges(Qt3DCore::QNodeId anim const QVector &channelResults, bool finalFrame); -Q_AUTOTEST_EXPORT -QVector buildPropertyMappings(Handler *handler, - const AnimationClip *clip, - const ChannelMapper *mapper); - Q_AUTOTEST_EXPORT QVector buildPropertyMappings(const QVector &channelMappings, const QVector &channelNamesAndTypes, -- cgit v1.2.3