[Bf-blender-cvs] [38bbc92] master: Cycles: Add utility functions to get a ShaderInput / ShaderOutput by name.

Thomas Dinges noreply at git.blender.org
Wed Nov 18 17:13:17 CET 2015


Commit: 38bbc920a60c39e18f866175563a63e834a10f5e
Author: Thomas Dinges
Date:   Wed Nov 18 17:12:26 2015 +0100
Branches: master
https://developer.blender.org/rB38bbc920a60c39e18f866175563a63e834a10f5e

Cycles: Add utility functions to get a ShaderInput / ShaderOutput by name.

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

M	intern/cycles/render/graph.cpp
M	intern/cycles/render/graph.h

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

diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index f5ff091..16e1ef7 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -117,6 +117,30 @@ ShaderOutput *ShaderNode::add_output(const char *name, ShaderSocketType type)
 	return output;
 }
 
+ShaderInput *ShaderNode::get_input(const char *name)
+{
+	foreach(ShaderInput *input, inputs) {
+		if(input->name == name)
+			return input;
+	}
+
+	/* Should never happen. */
+	assert(!"No Shader Input!");
+	return NULL;
+}
+
+ShaderOutput *ShaderNode::get_output(const char *name)
+{
+	foreach(ShaderOutput *output, outputs) {
+		if(output->name == name)
+			return output;
+	}
+
+	/* Should never happen. */
+	assert(!"No Shader Output!");
+	return NULL;
+}
+
 void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
 {
 	foreach(ShaderInput *input, inputs) {
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index 9117fd0..8169e60 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -189,6 +189,9 @@ public:
 	ShaderInput *add_input(const char *name, ShaderSocketType type, ShaderInput::DefaultValue value, int usage=ShaderInput::USE_ALL);
 	ShaderOutput *add_output(const char *name, ShaderSocketType type);
 
+	ShaderInput *get_input(const char *name);
+	ShaderOutput *get_output(const char *name);
+
 	virtual ShaderNode *clone() const = 0;
 	virtual void attributes(Shader *shader, AttributeRequestSet *attributes);
 	virtual void compile(SVMCompiler& compiler) = 0;




More information about the Bf-blender-cvs mailing list