From ce0fce2207fa3f5803aa7857419aefbd1c2d714f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 20 Aug 2017 17:36:16 +0200 Subject: Code cleanup: deduplicate some bsdf node methods. --- intern/cycles/render/nodes.cpp | 16 ++++++++-------- intern/cycles/render/nodes.h | 27 ++++++++++----------------- 2 files changed, 18 insertions(+), 25 deletions(-) (limited to 'intern') diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 689326f9795..2b682756c6a 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -1801,6 +1801,14 @@ BsdfBaseNode::BsdfBaseNode(const NodeType *node_type) special_type = SHADER_SPECIAL_TYPE_CLOSURE; } +bool BsdfBaseNode::has_bump() +{ + /* detect if anything is plugged into the normal input besides the default */ + ShaderInput *normal_in = input("Normal"); + return (normal_in && normal_in->link && + normal_in->link->parent->special_type != SHADER_SPECIAL_TYPE_GEOMETRY); +} + /* BSDF Closure */ BsdfNode::BsdfNode(const NodeType *node_type) @@ -1845,14 +1853,6 @@ void BsdfNode::compile(OSLCompiler& /*compiler*/) assert(0); } -bool BsdfNode::has_bump() -{ - /* detect if anything is plugged into the normal input besides the default */ - ShaderInput *normal_in = input("Normal"); - return (normal_in && normal_in->link && - normal_in->link->parent->special_type != SHADER_SPECIAL_TYPE_GEOMETRY); -} - /* Anisotropic BSDF Closure */ NODE_DEFINE(AnisotropicBsdfNode) diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index db47e2d92d5..ec4c7c7c50d 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -326,6 +326,16 @@ class BsdfBaseNode : public ShaderNode { public: BsdfBaseNode(const NodeType *node_type); + bool has_spatial_varying() { return true; } + virtual ClosureType get_closure_type() { return closure; } + virtual bool has_bump(); + + virtual bool equals(const ShaderNode& /*other*/) + { + /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */ + return false; + } + ClosureType closure; }; @@ -334,20 +344,11 @@ public: explicit BsdfNode(const NodeType *node_type); SHADER_NODE_BASE_CLASS(BsdfNode) - bool has_spatial_varying() { return true; } void compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2, ShaderInput *param3 = NULL, ShaderInput *param4 = NULL); - virtual ClosureType get_closure_type() { return closure; } - virtual bool has_bump(); float3 color; float3 normal; float surface_mix_weight; - - virtual bool equals(const ShaderNode& /*other*/) - { - /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */ - return false; - } }; class AnisotropicBsdfNode : public BsdfNode { @@ -374,7 +375,6 @@ class PrincipledBsdfNode : public BsdfBaseNode { public: SHADER_NODE_CLASS(PrincipledBsdfNode) - bool has_spatial_varying() { return true; } bool has_surface_bssrdf(); bool has_bssrdf_bump(); void compile(SVMCompiler& compiler, ShaderInput *metallic, ShaderInput *subsurface, ShaderInput *subsurface_radius, @@ -391,13 +391,6 @@ public: float surface_mix_weight; ClosureType distribution, distribution_orig; - virtual bool equals(const ShaderNode * /*other*/) - { - /* TODO(sergey): With some care BSDF nodes can be de-duplicated. */ - return false; - } - - ClosureType get_closure_type() { return closure; } bool has_integrator_dependency(); void attributes(Shader *shader, AttributeRequestSet *attributes); }; -- cgit v1.2.3