[Bf-blender-cvs] [adfd43db6b1] functions: new Node Instance Identifier node

Jacques Lucke noreply at git.blender.org
Fri Dec 20 18:23:10 CET 2019


Commit: adfd43db6b10f507fb0e47738dc681f0c6265d75
Author: Jacques Lucke
Date:   Fri Dec 20 15:22:21 2019 +0100
Branches: functions
https://developer.blender.org/rBadfd43db6b10f507fb0e47738dc681f0c6265d75

new Node Instance Identifier node

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

A	release/scripts/startup/nodes/function_nodes/node_instance_identifier.py
M	source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc

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

diff --git a/release/scripts/startup/nodes/function_nodes/node_instance_identifier.py b/release/scripts/startup/nodes/function_nodes/node_instance_identifier.py
new file mode 100644
index 00000000000..62b8d6641e6
--- /dev/null
+++ b/release/scripts/startup/nodes/function_nodes/node_instance_identifier.py
@@ -0,0 +1,12 @@
+import bpy
+from bpy.props import *
+from .. base import FunctionNode
+from .. node_builder import NodeBuilder
+
+
+class NodeInstanceIdentifierNode(bpy.types.Node, FunctionNode):
+    bl_idname = "fn_NodeInstanceIdentifierNode"
+    bl_label = "Node Instance Identifier"
+
+    def declaration(self, builder):
+        builder.fixed_output("identifier", "Identifier", "Text")
diff --git a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc
index 9e0392556f1..a729c21a799 100644
--- a/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc
+++ b/source/blender/functions/intern/inlined_tree_multi_function_network/mappings_nodes.cc
@@ -520,6 +520,18 @@ static void INSERT_join_text_list(VNodeMFNetworkBuilder &builder)
   builder.set_constructed_matching_fn<MF_JoinTextList>();
 }
 
+static void INSERT_node_instance_identifier(VNodeMFNetworkBuilder &builder)
+{
+  const XNode &xnode = builder.xnode();
+  std::string identifier = "";
+  for (const BKE::XParentNode *parent = xnode.parent(); parent; parent = parent->parent()) {
+    identifier = parent->vnode().name() + "/" + identifier;
+  }
+  identifier = "/nodeid/" + identifier + xnode.name();
+  std::cout << identifier << "\n";
+  builder.set_constructed_matching_fn<MF_ConstantValue<std::string>>(std::move(identifier));
+}
+
 void add_inlined_tree_node_mapping_info(VTreeMultiFunctionMappings &mappings)
 {
   mappings.xnode_inserters.add_new("fn_CombineColorNode", INSERT_combine_color);
@@ -592,6 +604,8 @@ void add_inlined_tree_node_mapping_info(VTreeMultiFunctionMappings &mappings)
   mappings.xnode_inserters.add_new("fn_BooleanNotNode", INSERT_boolean_not);
 
   mappings.xnode_inserters.add_new("fn_JoinTextListNode", INSERT_join_text_list);
+  mappings.xnode_inserters.add_new("fn_NodeInstanceIdentifierNode",
+                                   INSERT_node_instance_identifier);
 }
 
 };  // namespace FN



More information about the Bf-blender-cvs mailing list