Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-06-30 19:03:02 +0300
committerJacques Lucke <jacques@blender.org>2020-06-30 19:18:48 +0300
commit67da2bd23a5496e5f2228a20e54c138c3d03d9eb (patch)
treec004c9a63600abd15b13960840f6065c976bb80b /source/blender/functions/intern
parentd67b7f3b5236d636d5bd35a917d13b9f06452df0 (diff)
Functions: add methods to multi-function network classes
Those are necessary to query and modify the network.
Diffstat (limited to 'source/blender/functions/intern')
-rw-r--r--source/blender/functions/intern/multi_function_network.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/functions/intern/multi_function_network.cc b/source/blender/functions/intern/multi_function_network.cc
index 269a32b73bd..93d062f3e5c 100644
--- a/source/blender/functions/intern/multi_function_network.cc
+++ b/source/blender/functions/intern/multi_function_network.cc
@@ -193,6 +193,44 @@ MFInputSocket &MFNetwork::add_output(StringRef name, MFDataType data_type)
return this->add_dummy(name, {data_type}, {}, {name}, {}).input(0);
}
+void MFNetwork::relink(MFOutputSocket &old_output, MFOutputSocket &new_output)
+{
+ BLI_assert(&old_output != &new_output);
+ for (MFInputSocket *input : old_output.targets()) {
+ input->m_origin = &new_output;
+ }
+ new_output.m_targets.extend(old_output.m_targets);
+ old_output.m_targets.clear();
+}
+
+void MFNetwork::remove(MFNode &node)
+{
+ for (MFInputSocket *socket : node.m_inputs) {
+ if (socket->m_origin != nullptr) {
+ socket->m_origin->m_targets.remove_first_occurrence_and_reorder(socket);
+ }
+ m_socket_or_null_by_id[socket->m_id] = nullptr;
+ }
+ for (MFOutputSocket *socket : node.m_outputs) {
+ for (MFInputSocket *other : socket->m_targets) {
+ other->m_origin = nullptr;
+ }
+ m_socket_or_null_by_id[socket->m_id] = nullptr;
+ }
+ node.destruct_sockets();
+ if (node.is_dummy()) {
+ MFDummyNode &dummy_node = node.as_dummy();
+ dummy_node.~MFDummyNode();
+ m_dummy_nodes.remove_contained(&dummy_node);
+ }
+ else {
+ MFFunctionNode &function_node = node.as_function();
+ function_node.~MFFunctionNode();
+ m_function_nodes.remove_contained(&function_node);
+ }
+ m_node_or_null_by_id[node.m_id] = nullptr;
+}
+
std::string MFNetwork::to_dot() const
{
dot::DirectedGraph digraph;