[Bf-blender-cvs] [dfa3ed87611] functions-experimental-refactor: insert links function

Jacques Lucke noreply at git.blender.org
Tue Oct 22 13:55:08 CEST 2019


Commit: dfa3ed8761169b64da182eebc75b1cdbd5557947
Author: Jacques Lucke
Date:   Tue Oct 22 13:04:54 2019 +0200
Branches: functions-experimental-refactor
https://developer.blender.org/rBdfa3ed8761169b64da182eebc75b1cdbd5557947

insert links function

===================================================================

M	source/blender/blenkernel/BKE_multi_function.h
M	source/blender/modifiers/intern/MOD_functiondeform_cxx.cc

===================================================================

diff --git a/source/blender/blenkernel/BKE_multi_function.h b/source/blender/blenkernel/BKE_multi_function.h
index 403fafeb72e..a776ff8dcee 100644
--- a/source/blender/blenkernel/BKE_multi_function.h
+++ b/source/blender/blenkernel/BKE_multi_function.h
@@ -53,6 +53,16 @@ struct MFDataType {
     return *m_base_type;
   }
 
+  friend bool operator==(MFDataType a, MFDataType b)
+  {
+    return a.m_category == b.m_category && a.m_base_type == b.m_base_type;
+  }
+
+  friend bool operator!=(MFDataType a, MFDataType b)
+  {
+    return !(a == b);
+  }
+
  private:
   Category m_category = Category::None;
   const CPPType *m_base_type = nullptr;
diff --git a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
index f0acc90a00e..b890e236561 100644
--- a/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
+++ b/source/blender/modifiers/intern/MOD_functiondeform_cxx.cc
@@ -271,6 +271,22 @@ class VTreeMFNetworkBuilder {
     return false;
   }
 
+  MFBuilderOutputSocket &lookup_output_socket(const VirtualSocket &vsocket)
+  {
+    BLI_assert(vsocket.is_output());
+    MFBuilderSocket *socket = m_socket_map[vsocket.id()];
+    BLI_assert(socket != nullptr);
+    return socket->as_output();
+  }
+
+  MFBuilderInputSocket &lookup_input_socket(const VirtualSocket &vsocket)
+  {
+    BLI_assert(vsocket.is_input());
+    MFBuilderSocket *socket = m_socket_map[vsocket.id()];
+    BLI_assert(socket != nullptr);
+    return socket->as_input();
+  }
+
   std::unique_ptr<VTreeMFNetwork> build()
   {
     auto network = BLI::make_unique<MFNetwork>(std::move(m_builder));
@@ -345,6 +361,34 @@ static void insert_nodes(VTreeMFNetworkBuilder &builder, OwnedResources &resourc
   }
 }
 
+static bool insert_links(VTreeMFNetworkBuilder &builder, OwnedResources &resources)
+{
+  for (const VirtualSocket *to_vsocket : builder.vtree().inputs_with_links()) {
+    if (to_vsocket->links().size() > 1) {
+      continue;
+    }
+    BLI_assert(to_vsocket->links().size() == 1);
+
+    if (!builder.is_data_socket(*to_vsocket)) {
+      continue;
+    }
+
+    const VirtualSocket *from_vsocket = to_vsocket->links()[0];
+    if (!builder.is_data_socket(*from_vsocket)) {
+      return false;
+    }
+
+    auto &from_socket = builder.lookup_output_socket(*from_vsocket);
+    auto &to_socket = builder.lookup_input_socket(*to_vsocket);
+
+    if (from_socket.type() != to_socket.type()) {
+      return false;
+    }
+
+    builder.add_link(from_socket, to_socket);
+  }
+}
+
 static std::unique_ptr<BKE::MultiFunction> get_multi_function_by_node(VirtualNode *vnode)
 {
   StringRef idname = vnode->idname();



More information about the Bf-blender-cvs mailing list