From 38bbc920a60c39e18f866175563a63e834a10f5e Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 18 Nov 2015 17:12:26 +0100 Subject: Cycles: Add utility functions to get a ShaderInput / ShaderOutput by name. --- intern/cycles/render/graph.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'intern/cycles/render/graph.cpp') 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) { -- cgit v1.2.3