Fix: Clamping in Map Range node works incorrectly.

The clamp option in the Map Range node doesn't work correctly when the
inputs are linked. The code didn't put that into considration.

Reviewers: brecht

Differential Revision: https://developer.blender.org/D5987
This commit is contained in:
OmarSquircleArt 2019-10-04 15:18:08 +02:00
parent f025b625f4
commit 8afa93d82d
1 changed files with 12 additions and 2 deletions

View File

@ -5567,11 +5567,21 @@ void MapRangeNode::expand(ShaderGraph *graph)
ShaderOutput *result_out = output("Result");
if (!result_out->links.empty()) {
ClampNode *clamp_node = new ClampNode();
clamp_node->min = to_min;
clamp_node->max = to_max;
graph->add(clamp_node);
graph->relink(result_out, clamp_node->output("Result"));
graph->connect(result_out, clamp_node->input("Value"));
if (input("To Min")->link) {
graph->connect(input("To Min")->link, clamp_node->input("Min"));
}
else {
clamp_node->min = to_min;
}
if (input("To Max")->link) {
graph->connect(input("To Max")->link, clamp_node->input("Max"));
}
else {
clamp_node->max = to_max;
}
}
}
}