Code improvements + Mix node #30

Merged
Bogdan Nagirniak merged 18 commits from BogdanNagirniak/blender:matx-code-improvements into matx-export-material 2023-09-22 18:23:13 +02:00
Showing only changes of commit 273bb4d0e1 - Show all commits

View File

@ -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
{ {
if (value && min_val.value && max_val.value) {
return min(max_val).max(min_val); 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