Create parsing system that converts supported nodes and ignores unsupported #2

Merged
Bogdan Nagirniak merged 14 commits from Vasyl-Pidhirskyi/blender:BLEN-500 into matx-export-material 2023-08-28 12:29:46 +02:00
Showing only changes of commit 7b314dd80a - Show all commits

View File

@ -21,7 +21,7 @@ void NodeItem::set_input(const std::string &name, const NodeItem &res)
if (res.value) { if (res.value) {
set_input(name, res.value); set_input(name, res.value);
} }
else { else if (res.node) {
set_input(name, res.node); set_input(name, res.node);
} }
} }
@ -55,7 +55,7 @@ void NodeItem::set_input(const std::string &name, const MaterialX::NodePtr node)
NodeItem::operator bool() const NodeItem::operator bool() const
{ {
return !value && !node; return value || node;
} }
NodeParser::NodeParser(MaterialX::GraphElement *graph, NodeParser::NodeParser(MaterialX::GraphElement *graph,
@ -109,7 +109,7 @@ NodeItem NodeParser::get_input_link(const std::string &name)
NodeItem res = empty_value(); NodeItem res = empty_value();
const bNodeLink *link = node->input_by_identifier(name).link; const bNodeLink *link = node->input_by_identifier(name).link;
if (!link->is_used()) { if (!(link && link->is_used())) {
return res; return res;
} }
@ -118,7 +118,7 @@ NodeItem NodeParser::get_input_link(const std::string &name)
/* Passing NODE_REROUTE nodes */ /* Passing NODE_REROUTE nodes */
while (in_node->type == NODE_REROUTE) { while (in_node->type == NODE_REROUTE) {
link = in_node->input_socket(0).link; link = in_node->input_socket(0).link;
if (!link->is_used()) { if (!(link && link->is_used())) {
return res; return res;
} }
in_node = link->fromnode; in_node = link->fromnode;
@ -146,7 +146,7 @@ NodeItem NodeParser::get_input_value(const std::string &name)
{ {
NodeItem res = get_input_link(name); NodeItem res = get_input_link(name);
if (!res) { if (!res) {
res = get_input_value(name); res = get_input_default(name);
} }
return res; return res;
} }