Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Dinges <blender@dingto.org>2015-11-18 19:12:26 +0300
committerThomas Dinges <blender@dingto.org>2015-11-18 19:12:26 +0300
commit38bbc920a60c39e18f866175563a63e834a10f5e (patch)
tree2c8f17e613d37d6cdd05d021e52d05c358e667af /intern/cycles/render
parentc2c11debe5abf52afa46b99c6dc6a5acd12d97ae (diff)
Cycles: Add utility functions to get a ShaderInput / ShaderOutput by name.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/graph.cpp24
-rw-r--r--intern/cycles/render/graph.h3
2 files changed, 27 insertions, 0 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index f5ff091623b..16e1ef7a493 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 9117fd03a95..8169e606f1a 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;