1
1
Fork 0

Fix linux build #33

Merged
Bogdan Nagirniak merged 7 commits from BogdanNagirniak/blender:matx-linux-build-fix into matx-export-material 2023-09-24 07:42:31 +02:00
4 changed files with 39 additions and 9 deletions
Showing only changes of commit cd737eb674 - Show all commits

View File

@ -31,10 +31,16 @@ NodeItem GroupNodeParser::compute()
graph = group_graph.get();
#endif
NodeItem out =
GroupOutputNodeParser(
graph, depsgraph_, material_, node_out, socket_out_, to_type_, this, export_image_fn_)
.compute_full();
NodeItem out = GroupOutputNodeParser(graph,
depsgraph_,
material_,
node_out,
socket_out_,
to_type_,
this,
use_group_default_,
export_image_fn_)
.compute_full();
#ifdef USE_MATERIALX_NODEGRAPH
/* We have to be in NodeParser's graph_, therefore copying output */
@ -121,6 +127,9 @@ NodeItem GroupInputNodeParser::compute()
}
return create_input(in_name(), value);
#else
if (use_group_default_) {
return group_parser_->get_input_value(socket_out_->index(), to_type_);
}
return group_parser_->get_input_link(socket_out_->index(), to_type_);
#endif
}

View File

@ -71,6 +71,7 @@ MaterialX::DocumentPtr export_to_materialx(Depsgraph *depsgraph,
NodeItem::Type::Material,
nullptr,
NodeItem(doc.get()),
false,
export_image_fn};
output_node->typeinfo->materialx_fn(&data, output_node, nullptr);
}
@ -82,6 +83,7 @@ MaterialX::DocumentPtr export_to_materialx(Depsgraph *depsgraph,
nullptr,
NodeItem::Type::Material,
nullptr,
false,
export_image_fn)
.compute_error();
}
@ -94,6 +96,7 @@ MaterialX::DocumentPtr export_to_materialx(Depsgraph *depsgraph,
nullptr,
NodeItem::Type::Material,
nullptr,
false,
export_image_fn)
.compute();
}

View File

@ -21,6 +21,7 @@ NodeParser::NodeParser(MaterialX::GraphElement *graph,
const bNodeSocket *socket_out,
NodeItem::Type to_type,
GroupNodeParser *group_parser,
bool use_group_default,
ExportImageFunction export_image_fn)
: graph_(graph),
depsgraph_(depsgraph),
@ -29,6 +30,7 @@ NodeParser::NodeParser(MaterialX::GraphElement *graph,
socket_out_(socket_out),
to_type_(to_type),
group_parser_(group_parser),
use_group_default_(use_group_default),
export_image_fn_(export_image_fn)
{
}
@ -199,7 +201,9 @@ NodeItem NodeParser::get_default(const bNodeSocket &socket, NodeItem::Type to_ty
return res.convert(to_type);
}
NodeItem NodeParser::get_input_link(const bNodeSocket &socket, NodeItem::Type to_type)
NodeItem NodeParser::get_input_link(const bNodeSocket &socket,
NodeItem::Type to_type,
bool use_group_default)
{
const bNodeLink *link = socket.link;
if (!(link && link->is_used())) {
@ -225,6 +229,7 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket, NodeItem::Type to
link->fromsock,
to_type,
group_parser_,
use_group_default,
export_image_fn_)
.compute_full();
}
@ -236,6 +241,7 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket, NodeItem::Type to
link->fromsock,
to_type,
group_parser_,
use_group_default,
export_image_fn_)
.compute_full();
}
@ -248,15 +254,21 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket, NodeItem::Type to
return empty();
}
NodeParserData data = {
graph_, depsgraph_, material_, to_type, group_parser_, empty(), export_image_fn_};
NodeParserData data = {graph_,
depsgraph_,
material_,
to_type,
group_parser_,
empty(),
use_group_default,
export_image_fn_};
from_node->typeinfo->materialx_fn(&data, const_cast<bNode *>(from_node), link->fromsock);
return data.result;
}
NodeItem NodeParser::get_input_value(const bNodeSocket &socket, NodeItem::Type to_type)
{
NodeItem res = get_input_link(socket, to_type);
NodeItem res = get_input_link(socket, to_type, true);
if (!res) {
res = get_default(socket, to_type);
}

View File

@ -33,6 +33,7 @@ class NodeParser {
const bNodeSocket *socket_out_;
NodeItem::Type to_type_;
GroupNodeParser *group_parser_;
bool use_group_default_;
ExportImageFunction export_image_fn_;
public:
@ -43,6 +44,7 @@ class NodeParser {
const bNodeSocket *socket_out,
NodeItem::Type to_type,
GroupNodeParser *group_parser,
bool use_group_default,
ExportImageFunction export_image_fn);
virtual ~NodeParser() = default;
@ -71,7 +73,9 @@ class NodeParser {
private:
NodeItem get_default(const bNodeSocket &socket, NodeItem::Type to_type);
NodeItem get_input_link(const bNodeSocket &socket, NodeItem::Type to_type);
NodeItem get_input_link(const bNodeSocket &socket,
NodeItem::Type to_type,
bool use_group_default = false);
NodeItem get_input_value(const bNodeSocket &socket, NodeItem::Type to_type);
};
@ -103,6 +107,7 @@ struct NodeParserData {
NodeItem::Type to_type;
GroupNodeParser *group_parser;
NodeItem result;
bool use_group_default;
ExportImageFunction export_image_fn;
};
@ -130,6 +135,7 @@ struct NodeParserData {
out, \
d->to_type, \
d->group_parser, \
d->use_group_default, \
d->export_image_fn) \
.compute_full(); \
}