forked from blender/blender
Code improvements + Mix node #30
@ -338,7 +338,19 @@ NodeItem NodeItem::mix(const NodeItem &val1, const NodeItem &val2) const
|
|||||||
|
|
||||||
NodeItem NodeItem::clamp(const NodeItem &min_val, const NodeItem &max_val) const
|
NodeItem NodeItem::clamp(const NodeItem &min_val, const NodeItem &max_val) const
|
||||||
{
|
{
|
||||||
return min(max_val).max(min_val);
|
if (value && min_val.value && max_val.value) {
|
||||||
|
return min(max_val).max(min_val);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (min_val.type() == Type::Float && max_val.type() == Type::Float) {
|
||||||
|
return create_node("clamp", type(), {{"in", *this}, {"low", min_val}, {"high", max_val}});
|
||||||
|
}
|
||||||
|
|
||||||
|
Type type = this->type();
|
||||||
|
return create_node(
|
||||||
|
"clamp",
|
||||||
|
type,
|
||||||
|
{{"in", *this}, {"low", min_val.convert(type)}, {"high", max_val.convert(type)}});
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeItem NodeItem::clamp(float min_val, float max_val) const
|
NodeItem NodeItem::clamp(float min_val, float max_val) const
|
||||||
|
Loading…
Reference in New Issue
Block a user