From a3f4ebdb6dcb3305cdfc75bcf14e7ffdbaa49139 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Sun, 23 Oct 2022 21:24:49 -0700 Subject: [PATCH] node/ui: limit amount of selectable nodes for performance --- app/widget/nodeparamview/nodeparamview.cpp | 11 +++++++++-- app/widget/nodeview/nodeview.cpp | 5 +++++ app/widget/nodeview/nodeview.h | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/widget/nodeparamview/nodeparamview.cpp b/app/widget/nodeparamview/nodeparamview.cpp index b0d6f1618..d17358fb2 100644 --- a/app/widget/nodeparamview/nodeparamview.cpp +++ b/app/widget/nodeparamview/nodeparamview.cpp @@ -697,13 +697,20 @@ void NodeParamView::QueueKeyframePositionUpdate() void NodeParamView::AddContext(Node *ctx) { + NodeParamViewContext *item = GetContextItemFromContext(ctx); + + // TEMP: Creating many NPV items is EXTREMELY slow so limit to one item per context for now. + // I have a better solution in the works to use one UI for several nodes, but I haven't + // done it yet, and this can severely affect productivity. + if (item->GetContexts().size() == 1) { + return; + } + // Queued so that if any further work is done in connecting this node to the context, it'll be // done before our sorting function is called connect(ctx, &Node::NodeAddedToContext, this, &NodeParamView::NodeAddedToContext, Qt::QueuedConnection); connect(ctx, &Node::NodeRemovedFromContext, this, &NodeParamView::NodeRemovedFromContext, Qt::QueuedConnection); - NodeParamViewContext *item = GetContextItemFromContext(ctx); - item->AddContext(ctx); item->setVisible(true); diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index cf1610b02..0a9ecee08 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -44,6 +44,7 @@ namespace olive { const double NodeView::kMinimumScale = 0.1; +const int NodeView::kMaximumContexts = 10; NodeView::NodeView(QWidget *parent) : HandMovableView(parent), @@ -102,6 +103,10 @@ void NodeView::SetContexts(const QVector &nodes) // Add contexts that are now in the list foreach (Node *n, nodes) { + if (scene_.context_map().size() >= kMaximumContexts) { + break; + } + if (!contexts_.contains(n)) { AddContext(n); } diff --git a/app/widget/nodeview/nodeview.h b/app/widget/nodeview/nodeview.h index bf2d0ee0d..01e1dd487 100644 --- a/app/widget/nodeview/nodeview.h +++ b/app/widget/nodeview/nodeview.h @@ -235,6 +235,8 @@ private: static const double kMinimumScale; + static const int kMaximumContexts; + private slots: /** * @brief Receiver for when the scene's selected items change