From eb2ee7212e16547e2a79b967d2ed37d88b0f2565 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Mon, 22 Aug 2016 11:11:45 +0300 Subject: Fix T49136: full constant Curves with zero Fac input crashes in assert. The if branches were reordered when the original patch was committed, which broke the implicit non-NULL guarantee on link. To prevent re-occurrence, add a couple of unit tests. --- intern/cycles/render/nodes.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'intern/cycles/render') diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 4f54b86fe4a..0304d6d95d1 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -4846,12 +4846,8 @@ void CurvesNode::constant_fold(const ConstantFolder& folder, ShaderInput *value_ { ShaderInput *fac_in = input("Fac"); - /* remove no-op node */ - if(!fac_in->link && fac == 0.0f) { - folder.bypass(value_in->link); - } /* evaluate fully constant node */ - else if(folder.all_inputs_constant()) { + if(folder.all_inputs_constant()) { if (curves.size() == 0) return; @@ -4864,6 +4860,11 @@ void CurvesNode::constant_fold(const ConstantFolder& folder, ShaderInput *value_ folder.make_constant(interp(value, result, fac)); } + /* remove no-op node */ + else if(!fac_in->link && fac == 0.0f) { + /* link is not null because otherwise all inputs are constant */ + folder.bypass(value_in->link); + } } void CurvesNode::compile(SVMCompiler& compiler, int type, ShaderInput *value_in, ShaderOutput *value_out) -- cgit v1.2.3