diff --git a/app/node/node.cpp b/app/node/node.cpp index 4d4f362cf..b26a95d93 100644 --- a/app/node/node.cpp +++ b/app/node/node.cpp @@ -1555,64 +1555,6 @@ void Node::GenerateFrame(FramePtr frame, const GenerateJob &job) const Q_UNUSED(job) } -bool Node::OutputsTo(Node *n, bool recursively, const OutputConnections &ignore_edges, const OutputConnection &added_edge) const -{ - for (const OutputConnection& conn : output_connections_) { - if (std::find(ignore_edges.cbegin(), ignore_edges.cend(), conn) != ignore_edges.cend()) { - // If this edge is in the "ignore edges" list, skip it - continue; - } - - Node* connected = conn.second.node(); - - if (connected == n) { - return true; - } else if (recursively && connected->OutputsTo(n, recursively, ignore_edges, added_edge)) { - return true; - } else if (added_edge.first == this) { - Node *proposed_connected = added_edge.second.node(); - - if (proposed_connected == n) { - return true; - } else if (recursively && proposed_connected->OutputsTo(n, recursively, ignore_edges, added_edge)) { - return true; - } - } - } - - return false; -} - -bool Node::OutputsTo(const QString &id, bool recursively) const -{ - for (const OutputConnection& conn : output_connections_) { - Node* connected = conn.second.node(); - - if (connected->id() == id) { - return true; - } else if (recursively && connected->OutputsTo(id, recursively)) { - return true; - } - } - - return false; -} - -bool Node::OutputsTo(const NodeInput &input, bool recursively) const -{ - for (const OutputConnection& conn : output_connections_) { - const NodeInput& connected = conn.second; - - if (connected == input) { - return true; - } else if (recursively && connected.node()->OutputsTo(input, recursively)) { - return true; - } - } - - return false; -} - bool Node::InputsFrom(Node *n, bool recursively) const { for (auto it=input_connections_.cbegin(); it!=input_connections_.cend(); it++) { @@ -1643,28 +1585,6 @@ bool Node::InputsFrom(const QString &id, bool recursively) const return false; } -int Node::GetNumberOfRoutesTo(Node *n) const -{ - bool outputs_directly = false; - int routes = 0; - - foreach (const OutputConnection& conn, output_connections_) { - Node* connected_node = conn.second.node(); - - if (connected_node == n) { - outputs_directly = true; - } else { - routes += connected_node->GetNumberOfRoutesTo(n); - } - } - - if (outputs_directly) { - routes++; - } - - return routes; -} - void Node::DisconnectAll() { // Disconnect inputs (copy map since internal map will change as we disconnect) diff --git a/app/node/node.h b/app/node/node.h index f5e5a8485..8fa933979 100644 --- a/app/node/node.h +++ b/app/node/node.h @@ -786,30 +786,6 @@ public: */ virtual void GenerateFrame(FramePtr frame, const GenerateJob &job) const; - /** - * @brief Returns whether this Node outputs to `n` - * - * @param n - * - * The node instance to check. - * - * @param recursively - * - * Whether to keep traversing down outputs to find this node (TRUE) or stick to immediate outputs - * (FALSE). - */ - bool OutputsTo(Node* n, bool recursively, const OutputConnections &ignore_edges = OutputConnections(), const OutputConnection &added_edge = OutputConnection()) const; - - /** - * @brief Same as OutputsTo(Node*), but for a node ID rather than a specific instance. - */ - bool OutputsTo(const QString& id, bool recursively) const; - - /** - * @brief Same as OutputsTo(Node*), but for a specific node input rather than just a node. - */ - bool OutputsTo(const NodeInput &input, bool recursively) const; - /** * @brief Returns whether this node ever receives an input from a particular node instance */ @@ -820,7 +796,6 @@ public: */ bool InputsFrom(const QString& id, bool recursively) const; - /** * @brief Find inputs that `output` outputs to in order to arrive at this node * @@ -829,11 +804,6 @@ public: */ QVector FindWaysNodeArrivesHere(const Node *output) const; - /** - * @brief Determines how many paths go from this node out to another node - */ - int GetNumberOfRoutesTo(Node* n) const; - /** * @brief Severs all input and output connections */ @@ -866,12 +836,6 @@ public: template static QVector FindInputNodesConnectedToInput(const NodeInput &input, int maximum = 0); - template - /** - * @brief Find a node of a certain type that this Node outputs to - */ - QVector FindOutputNode(); - /** * @brief Convert a pointer to a value that can be sent between NodeParams */ @@ -1413,9 +1377,6 @@ private: template static void FindInputNodeInternal(const Node* n, QVector& list, int maximum); - template - static void FindOutputNodeInternal(const Node* n, QVector& list); - QVector GetDependenciesInternal(bool traverse, bool exclusive_only) const; void ParameterValueChanged(const QString &input, int element, const olive::TimeRange &range); @@ -1573,31 +1534,6 @@ T* Node::ValueToPtr(const QVariant &ptr) return reinterpret_cast(ptr.value()); } -template -void Node::FindOutputNodeInternal(const Node* n, QVector& list) -{ - foreach (const OutputConnection& output, n->output_connections_) { - Node* connected = output.second.node(); - T* cast_test = dynamic_cast(connected); - - if (cast_test) { - list.append(cast_test); - } - - FindOutputNodeInternal(connected, list); - } -} - -template -QVector Node::FindOutputNode() -{ - QVector list; - - FindOutputNodeInternal(this, list); - - return list; -} - using NodePtr = std::shared_ptr; class NodeSetPositionCommand : public UndoCommand diff --git a/app/widget/nodeview/nodeview.cpp b/app/widget/nodeview/nodeview.cpp index 0a9ecee08..97a818fe3 100644 --- a/app/widget/nodeview/nodeview.cpp +++ b/app/widget/nodeview/nodeview.cpp @@ -1043,7 +1043,7 @@ void NodeView::ProcessMovingAttachedNodes(const QPoint &pos) } } - if (new_drop_edge->input().node()->OutputsTo(attached_node, true)) { + if (attached_node->InputsFrom(new_drop_edge->input().node(), true)) { drop_input_.Reset(); } @@ -1079,7 +1079,7 @@ QVector NodeView::ProcessDroppingAttachedNodes(MultiUndoCommand *command, for (int i=0; iOutputsTo(ai.node, true)) { + if (ai.node->InputsFrom(select_context, true)) { attached.removeAt(i); } else if (select_context->ContextContainsNode(ai.node)) { select_nodes.append(ai.node); @@ -1118,7 +1118,7 @@ QVector NodeView::ProcessDroppingAttachedNodes(MultiUndoCommand *command, Node* dropping_node = nullptr; foreach (const AttachedItem &ai, attached) { - if (ai.item && !select_context->OutputsTo(ai.node, true)) { + if (ai.item && !ai.node->InputsFrom(select_context, true)) { dropping_node = ai.node; break; } @@ -1325,7 +1325,7 @@ void NodeView::PositionNewEdge(const QPoint &pos) // Filter out connecting to a node that connects to us or an item of the same type if (item_at_cursor - && ((create_edge_from_output_ && item_at_cursor->GetNode()->OutputsTo(source_item->GetNode(), true)) + && ((create_edge_from_output_ && source_item->GetNode()->InputsFrom(item_at_cursor->GetNode(), true)) || (!create_edge_from_output_ && item_at_cursor->GetNode()->InputsFrom(source_item->GetNode(), true)) || (create_edge_from_output_ == item_at_cursor->IsOutputItem()))) { item_at_cursor = nullptr; @@ -1412,7 +1412,7 @@ void NodeView::GroupNodes() // Default to the first node we find that doesn't output to a node inside the group output_passthrough = nodes_to_group.first(); foreach (Node *potential_in, nodes_to_group) { - if (potential_in != n && !n->OutputsTo(potential_in, false)) { + if (potential_in != n && !potential_in->InputsFrom(n, false)) { output_passthrough = n; break; } diff --git a/app/widget/timelinewidget/tool/import.cpp b/app/widget/timelinewidget/tool/import.cpp index caa0037ed..214056f2c 100644 --- a/app/widget/timelinewidget/tool/import.cpp +++ b/app/widget/timelinewidget/tool/import.cpp @@ -221,7 +221,7 @@ void ImportTool::FootageToGhosts(rational ghost_start, const DraggedFootageData for (auto it=sorted.cbegin(); it!=sorted.cend(); it++) { ViewerOutput* footage = it->first; - if (footage == sequence() || (sequence() && sequence()->OutputsTo(footage, true))) { + if (footage == sequence() || (sequence() && footage->InputsFrom(sequence(), true))) { // Prevent cyclical dependency continue; }