[Bf-blender-cvs] [d17a937] object_nodes: Expose the get_input function of the node graph just like get_output.

Lukas Tönne noreply at git.blender.org
Tue Dec 8 14:52:21 CET 2015


Commit: d17a937e894ab66596cff038ae2e9887efe7280d
Author: Lukas Tönne
Date:   Tue Dec 8 10:15:20 2015 +0100
Branches: object_nodes
https://developer.blender.org/rBd17a937e894ab66596cff038ae2e9887efe7280d

Expose the get_input function of the node graph just like get_output.

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

M	release/scripts/nodes/node_compiler.py
M	source/blender/blenvm/BVM_api.h
M	source/blender/blenvm/intern/bvm_api.cc
M	source/blender/makesrna/intern/rna_blenvm.c

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

diff --git a/release/scripts/nodes/node_compiler.py b/release/scripts/nodes/node_compiler.py
index 2b4b557..2f5e596 100644
--- a/release/scripts/nodes/node_compiler.py
+++ b/release/scripts/nodes/node_compiler.py
@@ -115,6 +115,10 @@ class NodeCompiler:
     def add_proxy(self, type):
         return self.add_node("PASS_%s" % type)
 
+    def graph_input(self, name):
+        in_node, in_socket = self.graph.get_input(name)
+        return OutputWrapper(in_node, in_node.outputs[in_socket])
+
     def graph_output(self, name):
         out_node, out_socket = self.graph.get_output(name)
         return InputWrapper(out_node, out_node.inputs[out_socket])
diff --git a/source/blender/blenvm/BVM_api.h b/source/blender/blenvm/BVM_api.h
index bf69651..6e3656f 100644
--- a/source/blender/blenvm/BVM_api.h
+++ b/source/blender/blenvm/BVM_api.h
@@ -63,6 +63,8 @@ int BVM_compile_get_object_index(struct BVMCompileContext *context, struct Objec
 
 struct BVMNodeInstance *BVM_nodegraph_add_node(struct BVMNodeGraph *graph, const char *type, const char *name);
 
+void BVM_nodegraph_get_input(struct BVMNodeGraph *graph, const char *name,
+                             struct BVMNodeInstance **node, const char **socket);
 void BVM_nodegraph_get_output(struct BVMNodeGraph *graph, const char *name,
                               struct BVMNodeInstance **node, const char **socket);
 
diff --git a/source/blender/blenvm/intern/bvm_api.cc b/source/blender/blenvm/intern/bvm_api.cc
index 1a5025c..a2d3223 100644
--- a/source/blender/blenvm/intern/bvm_api.cc
+++ b/source/blender/blenvm/intern/bvm_api.cc
@@ -106,6 +106,14 @@ BLI_INLINE bvm::TypeDesc *_TYPEDESC(struct BVMTypeDesc *typedesc)
 struct BVMNodeInstance *BVM_nodegraph_add_node(BVMNodeGraph *graph, const char *type, const char *name)
 { return (struct BVMNodeInstance *)_GRAPH(graph)->add_node(type, name); }
 
+void BVM_nodegraph_get_input(struct BVMNodeGraph *graph, const char *name,
+                             struct BVMNodeInstance **node, const char **socket)
+{
+	const bvm::NodeGraph::Input *input = _GRAPH(graph)->get_input(name);
+	if (node) *node = (BVMNodeInstance *)input->key.node;
+	if (socket) *socket = input->key.socket.c_str();
+}
+
 void BVM_nodegraph_get_output(struct BVMNodeGraph *graph, const char *name,
                               struct BVMNodeInstance **node, const char **socket)
 {
diff --git a/source/blender/makesrna/intern/rna_blenvm.c b/source/blender/makesrna/intern/rna_blenvm.c
index 495e496..e8e97a0 100644
--- a/source/blender/makesrna/intern/rna_blenvm.c
+++ b/source/blender/makesrna/intern/rna_blenvm.c
@@ -54,10 +54,16 @@ static struct BVMNodeInstance *rna_BVMNodeGraph_add_node(struct BVMNodeGraph *gr
 	return BVM_nodegraph_add_node(graph, type, name);
 }
 
+static void rna_BVMNodeGraph_get_input(struct BVMNodeGraph *graph, const char *name,
+                                       struct BVMNodeInstance **node, const char **socket)
+{
+	BVM_nodegraph_get_input(graph, name, node, socket);
+}
+
 static void rna_BVMNodeGraph_get_output(struct BVMNodeGraph *graph, const char *name,
                                         struct BVMNodeInstance **node, const char **socket)
 {
-	return BVM_nodegraph_get_output(graph, name, node, socket);
+	BVM_nodegraph_get_output(graph, name, node, socket);
 }
 
 /* ------------------------------------------------------------------------- */
@@ -447,6 +453,14 @@ static void rna_def_bvm_node_graph(BlenderRNA *brna)
 	parm = RNA_def_pointer(func, "node", "BVMNodeInstance", "Node", "");
 	RNA_def_function_return(func, parm);
 	
+	func = RNA_def_function(srna, "get_input", "rna_BVMNodeGraph_get_input");
+	RNA_def_function_ui_description(func, "Get a node/socket pair used as input of the graph");
+	RNA_def_string(func, "name", NULL, 0, "Name", "Input slot name");
+	parm = RNA_def_pointer(func, "node", "BVMNodeInstance", "Node", "");
+	RNA_def_function_output(func, parm);
+	parm = RNA_def_string(func, "socket", NULL, 0, "Socket", "Socket name");
+	RNA_def_function_output(func, parm);
+	
 	func = RNA_def_function(srna, "get_output", "rna_BVMNodeGraph_get_output");
 	RNA_def_function_ui_description(func, "Get a node/socket pair used as output of the graph");
 	RNA_def_string(func, "name", NULL, 0, "Name", "Output slot name");




More information about the Bf-blender-cvs mailing list