From 3a61e4375f630020ed54b660d71cb63f6da50043 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Wed, 23 May 2018 16:42:44 +0300 Subject: Make moving rows asynchronous MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the simplest way to ensure row indices stay in sync with asset graph indices in cases where multiple children are added to indices beyond the current child count (e.g. undoing a multiselection delete/move). This change also makes multiselection moves quite a bit more efficient, though in release builds the effect is barely noticeable. Also optimized a frequently used function getBindingForHandle to first look for the binding using the m_handlesMap as pretty much every time, except when called from onAssetCreated, the handle can be found from m_handlesMap. Task-number: QT3DS-1758 Change-Id: Ie95aef5f5f54c794db6a5d9c7515314b3182b65e Reviewed-by: Mahmoud Badri Reviewed-by: Tomi Korpipää --- .../Bindings/Qt3DSDMTimelineItemBinding.cpp | 50 ++++++---------------- 1 file changed, 14 insertions(+), 36 deletions(-) (limited to 'src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp') diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp index 7b70458f..999062da 100644 --- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp +++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp @@ -755,44 +755,22 @@ int Qt3DSDMTimelineItemBinding::getAnimatedPropertyIndex(int propertyHandle) con return -1; } -// Converts global asset graph index of a child into local time context index or vice versa -int Qt3DSDMTimelineItemBinding::convertIndex(int index, bool isAssetGraphIndex) const -{ - // If we are not a master slide object or scene root, global and local indexes always match - int retval = 0; - if (!IsMaster() && GetObjectType() != OBJTYPE_SCENE) { - retval = index; - } else { - qt3dsdm::Qt3DSDMInstanceHandle instance = GetInstance(); - if (instance.Valid()) { - Q3DStudio::CGraphIterator currentChildren; - Qt3DSDMSlideHandle activeSlide = m_TransMgr->GetDoc()->GetActiveSlide(); - GetAssetChildrenInTimeParent(instance, m_TransMgr->GetDoc(), AmITimeParent(), - currentChildren, activeSlide); - - Q3DStudio::CGraphIterator allChildren; - GetAssetChildren(m_TransMgr->GetDoc(), instance, allChildren); - - // Compare children to adjust the index - size_t skip = 0; - size_t maxCurrentIndex = currentChildren.GetCount() - 1; - size_t count = qMin(allChildren.GetCount(), size_t(index)); - for (size_t current = 0; current < count; ++current) { - size_t skipIndex = current - skip; - if (skipIndex > maxCurrentIndex || allChildren.GetResult(current) - != currentChildren.GetResult(skipIndex)) { - ++skip; - } - } - retval = index; - if (isAssetGraphIndex) - retval -= int(skip); - else - retval += int(skip); +void Qt3DSDMTimelineItemBinding::getTimeContextIndices(const QSet &children, + QMap &indexMap) +{ + qt3dsdm::Qt3DSDMInstanceHandle instance = GetInstance(); + if (instance.Valid()) { + Q3DStudio::CGraphIterator graphChildren; + Qt3DSDMSlideHandle activeSlide = m_TransMgr->GetDoc()->GetActiveSlide(); + GetAssetChildrenInTimeParent(instance, m_TransMgr->GetDoc(), AmITimeParent(), + graphChildren, activeSlide); + const size_t count = graphChildren.GetCount(); + for (size_t current = 0; current < count; ++current) { + auto handle = graphChildren.GetResult(current); + if (children.contains(handle)) + indexMap.insert(current, int(handle)); } } - - return retval; } void Qt3DSDMTimelineItemBinding::InsertKeyframe() -- cgit v1.2.3