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

This commit is contained in:
Thomas Dinges 2015-11-18 17:12:26 +01:00
parent c2c11debe5
commit 38bbc920a6
2 changed files with 27 additions and 0 deletions

@ -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) {

@ -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;