[Bf-blender-cvs] [00d9bed] object_nodes: New set of node types for 'arguments' which will act as stack entry placeholders.

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


Commit: 00d9beda03194b9cd3cf3dcbc956a9935ecd26e4
Author: Lukas Tönne
Date:   Tue Dec 8 10:24:16 2015 +0100
Branches: object_nodes
https://developer.blender.org/rB00d9beda03194b9cd3cf3dcbc956a9935ecd26e4

New set of node types for 'arguments' which will act as stack entry placeholders.

These are like value nodes in that an output socket stack entry is reserved for them.
However, like 'pass' nodes they don't actually perform an operation. Their purpose is
to provide a place on the stack for input arguments that other nodes can then read from.

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

M	source/blender/blenvm/compile/bvm_nodegraph.cc
M	source/blender/blenvm/compile/bvm_nodegraph.h

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

diff --git a/source/blender/blenvm/compile/bvm_nodegraph.cc b/source/blender/blenvm/compile/bvm_nodegraph.cc
index f6d75c7..1ec4e06 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.cc
+++ b/source/blender/blenvm/compile/bvm_nodegraph.cc
@@ -563,12 +563,7 @@ const NodeGraph::Output *NodeGraph::get_output(const string &name) const
 const NodeGraph::Input *NodeGraph::add_input(const string &name, BVMType type)
 {
 	BLI_assert(!get_input(name));
-	/* XXX these proxies (noop nodes) should be replaced by dedicated
-	 * 'argument' nodes, which ensure that we have a place on the stack
-	 * for writing input arguments to.
-	 * This also enables direct input->output connections.
-	 */
-	inputs.push_back(Input(name, add_proxy(TypeDesc(type))));
+	inputs.push_back(Input(name, add_argument_node(TypeDesc(type))));
 	return &inputs.back();
 }
 
@@ -615,6 +610,21 @@ SocketPair NodeGraph::add_value_node(Value *value)
 	return SocketPair(node, "value");
 }
 
+SocketPair NodeGraph::add_argument_node(const TypeDesc &typedesc)
+{
+	NodeInstance *node = NULL;
+	switch (typedesc.base_type) {
+		case BVM_FLOAT: node = add_node("ARG_FLOAT"); break;
+		case BVM_FLOAT3: node = add_node("ARG_FLOAT3"); break;
+		case BVM_FLOAT4: node = add_node("ARG_FLOAT4"); break;
+		case BVM_INT: node = add_node("ARG_INT"); break;
+		case BVM_MATRIX44: node = add_node("ARG_MATRIX44"); break;
+		case BVM_MESH: node = add_node("ARG_MESH"); break;
+		case BVM_POINTER: node = add_node("ARG_POINTER"); break;
+	}
+	return SocketPair(node, "value");
+}
+
 /* ------------------------------------------------------------------------- */
 /* Optimization */
 
@@ -1163,6 +1173,27 @@ static void register_opcode_node_types()
 	nt->add_input("value", BVM_MESH, __empty_mesh__);
 	nt->add_output("value", BVM_MESH, __empty_mesh__);
 	
+	nt = NodeGraph::add_function_node_type("ARG_FLOAT");
+	nt->add_output("value", BVM_FLOAT, 0.0f);
+	
+	nt = NodeGraph::add_function_node_type("ARG_FLOAT3");
+	nt->add_output("value", BVM_FLOAT3, float3(0.0f, 0.0f, 0.0f));
+	
+	nt = NodeGraph::add_function_node_type("ARG_FLOAT4");
+	nt->add_output("value", BVM_FLOAT4, float4(0.0f, 0.0f, 0.0f, 0.0f));
+	
+	nt = NodeGraph::add_function_node_type("ARG_INT");
+	nt->add_output("value", BVM_INT, 0);
+	
+	nt = NodeGraph::add_function_node_type("ARG_MATRIX44");
+	nt->add_output("value", BVM_MATRIX44, matrix44::identity());
+	
+	nt = NodeGraph::add_function_node_type("ARG_POINTER");
+	nt->add_output("value", BVM_POINTER, PointerRNA_NULL);
+	
+	nt = NodeGraph::add_function_node_type("ARG_MESH");
+	nt->add_output("value", BVM_MESH, __empty_mesh__);
+	
 	nt = NodeGraph::add_pass_node_type("VALUE_FLOAT");
 	nt->add_input("value", BVM_FLOAT, 0.0f, VALUE_CONSTANT);
 	nt->add_output("value", BVM_FLOAT, 0.0f);
diff --git a/source/blender/blenvm/compile/bvm_nodegraph.h b/source/blender/blenvm/compile/bvm_nodegraph.h
index 1545ef7..6b2aebc 100644
--- a/source/blender/blenvm/compile/bvm_nodegraph.h
+++ b/source/blender/blenvm/compile/bvm_nodegraph.h
@@ -330,6 +330,7 @@ protected:
 	
 	SocketPair add_proxy(const TypeDesc &typedesc, Value *default_value = NULL);
 	SocketPair add_value_node(Value *value);
+	SocketPair add_argument_node(const TypeDesc &typedesc);
 	
 	void remove_all_nodes();
 	SocketPair find_root(const SocketPair &key);




More information about the Bf-blender-cvs mailing list