Cycles: De-duplicate utility functions in ccl::Graph
This commit is contained in:
@@ -96,10 +96,11 @@ ShaderNode::~ShaderNode()
|
|||||||
|
|
||||||
ShaderInput *ShaderNode::input(const char *name)
|
ShaderInput *ShaderNode::input(const char *name)
|
||||||
{
|
{
|
||||||
foreach(ShaderInput *socket, inputs)
|
foreach(ShaderInput *socket, inputs) {
|
||||||
if(strcmp(socket->name, name) == 0)
|
if(strcmp(socket->name, name) == 0)
|
||||||
return socket;
|
return socket;
|
||||||
|
}
|
||||||
|
assert(!"Requested shader input does not exist");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@ ShaderOutput *ShaderNode::output(const char *name)
|
|||||||
foreach(ShaderOutput *socket, outputs)
|
foreach(ShaderOutput *socket, outputs)
|
||||||
if(strcmp(socket->name, name) == 0)
|
if(strcmp(socket->name, name) == 0)
|
||||||
return socket;
|
return socket;
|
||||||
|
assert(!"Requested shader output does not exist");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,30 +146,6 @@ ShaderOutput *ShaderNode::add_output(const char *name, ShaderSocketType type)
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderInput *ShaderNode::get_input(const char *name)
|
|
||||||
{
|
|
||||||
foreach(ShaderInput *input, inputs) {
|
|
||||||
if(strcmp(input->name, name) == 0)
|
|
||||||
return input;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Should never happen. */
|
|
||||||
assert(!"No Shader Input!");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ShaderOutput *ShaderNode::get_output(const char *name)
|
|
||||||
{
|
|
||||||
foreach(ShaderOutput *output, outputs) {
|
|
||||||
if(strcmp(output->name, name) == 0)
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Should never happen. */
|
|
||||||
assert(!"No Shader Output!");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
|
void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
|
||||||
{
|
{
|
||||||
foreach(ShaderInput *input, inputs) {
|
foreach(ShaderInput *input, inputs) {
|
||||||
|
@@ -190,9 +190,6 @@ public:
|
|||||||
ShaderInput *add_input(const char *name, ShaderSocketType type, ShaderInput::DefaultValue value, int usage=ShaderInput::USE_ALL);
|
ShaderInput *add_input(const char *name, ShaderSocketType type, ShaderInput::DefaultValue value, int usage=ShaderInput::USE_ALL);
|
||||||
ShaderOutput *add_output(const char *name, ShaderSocketType type);
|
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 ShaderNode *clone() const = 0;
|
||||||
virtual void attributes(Shader *shader, AttributeRequestSet *attributes);
|
virtual void attributes(Shader *shader, AttributeRequestSet *attributes);
|
||||||
virtual void compile(SVMCompiler& compiler) = 0;
|
virtual void compile(SVMCompiler& compiler) = 0;
|
||||||
|
@@ -1891,7 +1891,7 @@ void GlossyBsdfNode::simplify_settings(Scene *scene)
|
|||||||
/* Fallback to Sharp closure for Roughness close to 0.
|
/* Fallback to Sharp closure for Roughness close to 0.
|
||||||
* Note: Keep the epsilon in sync with kernel!
|
* Note: Keep the epsilon in sync with kernel!
|
||||||
*/
|
*/
|
||||||
ShaderInput *roughness_input = get_input("Roughness");
|
ShaderInput *roughness_input = input("Roughness");
|
||||||
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
||||||
distribution = ustring("Sharp");
|
distribution = ustring("Sharp");
|
||||||
}
|
}
|
||||||
@@ -1905,7 +1905,7 @@ void GlossyBsdfNode::simplify_settings(Scene *scene)
|
|||||||
|
|
||||||
bool GlossyBsdfNode::has_integrator_dependency()
|
bool GlossyBsdfNode::has_integrator_dependency()
|
||||||
{
|
{
|
||||||
ShaderInput *roughness_input = get_input("Roughness");
|
ShaderInput *roughness_input = input("Roughness");
|
||||||
return !roughness_input->link && roughness_input->value.x <= 1e-4f;
|
return !roughness_input->link && roughness_input->value.x <= 1e-4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1960,7 +1960,7 @@ void GlassBsdfNode::simplify_settings(Scene *scene)
|
|||||||
/* Fallback to Sharp closure for Roughness close to 0.
|
/* Fallback to Sharp closure for Roughness close to 0.
|
||||||
* Note: Keep the epsilon in sync with kernel!
|
* Note: Keep the epsilon in sync with kernel!
|
||||||
*/
|
*/
|
||||||
ShaderInput *roughness_input = get_input("Roughness");
|
ShaderInput *roughness_input = input("Roughness");
|
||||||
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
||||||
distribution = ustring("Sharp");
|
distribution = ustring("Sharp");
|
||||||
}
|
}
|
||||||
@@ -1974,7 +1974,7 @@ void GlassBsdfNode::simplify_settings(Scene *scene)
|
|||||||
|
|
||||||
bool GlassBsdfNode::has_integrator_dependency()
|
bool GlassBsdfNode::has_integrator_dependency()
|
||||||
{
|
{
|
||||||
ShaderInput *roughness_input = get_input("Roughness");
|
ShaderInput *roughness_input = input("Roughness");
|
||||||
return !roughness_input->link && roughness_input->value.x <= 1e-4f;
|
return !roughness_input->link && roughness_input->value.x <= 1e-4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2029,7 +2029,7 @@ void RefractionBsdfNode::simplify_settings(Scene *scene)
|
|||||||
/* Fallback to Sharp closure for Roughness close to 0.
|
/* Fallback to Sharp closure for Roughness close to 0.
|
||||||
* Note: Keep the epsilon in sync with kernel!
|
* Note: Keep the epsilon in sync with kernel!
|
||||||
*/
|
*/
|
||||||
ShaderInput *roughness_input = get_input("Roughness");
|
ShaderInput *roughness_input = input("Roughness");
|
||||||
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
if(!roughness_input->link && roughness_input->value.x <= 1e-4f) {
|
||||||
distribution = ustring("Sharp");
|
distribution = ustring("Sharp");
|
||||||
}
|
}
|
||||||
@@ -2043,7 +2043,7 @@ void RefractionBsdfNode::simplify_settings(Scene *scene)
|
|||||||
|
|
||||||
bool RefractionBsdfNode::has_integrator_dependency()
|
bool RefractionBsdfNode::has_integrator_dependency()
|
||||||
{
|
{
|
||||||
ShaderInput *roughness_input = get_input("Roughness");
|
ShaderInput *roughness_input = input("Roughness");
|
||||||
return !roughness_input->link && roughness_input->value.x <= 1e-4f;
|
return !roughness_input->link && roughness_input->value.x <= 1e-4f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user