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 52 additions and 43 deletions
Showing only changes of commit 6c54864245 - Show all commits

View File

@ -9,6 +9,21 @@
namespace blender::nodes::materialx {
GroupNodeParser::GroupNodeParser(MaterialX::GraphElement *graph,
const Depsgraph *depsgraph,
const Material *material,
const bNode *node,
const bNodeSocket *socket_out,
NodeItem::Type to_type,
GroupNodeParser *group_parser,
ExportImageFunction export_image_fn,
bool use_group_default)
: NodeParser(
graph, depsgraph, material, node, socket_out, to_type, group_parser, export_image_fn),
use_group_default_(use_group_default)
{
}
NodeItem GroupNodeParser::compute()
{
NodeItem res = empty();
@ -31,9 +46,15 @@ NodeItem GroupNodeParser::compute()
graph = group_graph.get();
#endif
NodeItem out =
GroupOutputNodeParser(
graph, depsgraph_, material_, node_out, socket_out_, to_type_, this, export_image_fn_)
NodeItem out = GroupOutputNodeParser(graph,
depsgraph_,
material_,
node_out,
socket_out_,
to_type_,
this,
export_image_fn_,
use_group_default_)
.compute_full();
#ifdef USE_MATERIALX_NODEGRAPH
@ -74,7 +95,10 @@ NodeItem GroupOutputNodeParser::compute()
}
return outputs[socket_out_->index()];
#else
if (use_group_default_) {
return get_input_value(socket_out_->index(), to_type_);
}
return get_input_link(socket_out_->index(), to_type_);
#endif
}
@ -108,21 +132,6 @@ std::string GroupOutputNodeParser::out_name(const bNodeSocket *out_socket)
return MaterialX::createValidName(std::string("out_") + out_socket->name);
}
GroupInputNodeParser::GroupInputNodeParser(MaterialX::GraphElement *graph,
const Depsgraph *depsgraph,
const Material *material,
const bNode *node,
const bNodeSocket *socket_out,
NodeItem::Type to_type,
GroupNodeParser *group_parser,
bool use_group_default,
ExportImageFunction export_image_fn)
: NodeParser(
graph, depsgraph, material, node, socket_out, to_type, group_parser, export_image_fn),
use_group_default_(use_group_default)
{
}
NodeItem GroupInputNodeParser::compute()
{
#ifdef USE_MATERIALX_NODEGRAPH

View File

@ -15,18 +15,28 @@ namespace blender::nodes::materialx {
class GroupInputNodeParser;
class GroupNodeParser : public NodeParser {
friend NodeParser;
friend GroupInputNodeParser;
protected:
bool use_group_default_;
public:
using NodeParser::NodeParser;
GroupNodeParser(MaterialX::GraphElement *graph,
const Depsgraph *depsgraph,
const Material *material,
const bNode *node,
const bNodeSocket *socket_out,
NodeItem::Type to_type,
GroupNodeParser *group_parser,
ExportImageFunction export_image_fn,
bool use_group_default);
NodeItem compute() override;
NodeItem compute_full() override;
};
class GroupOutputNodeParser : public NodeParser {
class GroupOutputNodeParser : public GroupNodeParser {
public:
using NodeParser::NodeParser;
using GroupNodeParser::GroupNodeParser;
NodeItem compute() override;
NodeItem compute_full() override;
@ -34,20 +44,9 @@ class GroupOutputNodeParser : public NodeParser {
static std::string out_name(const bNodeSocket *out_socket);
};
class GroupInputNodeParser : public NodeParser {
private:
bool use_group_default_;
class GroupInputNodeParser : public GroupNodeParser {
public:
GroupInputNodeParser(MaterialX::GraphElement *graph,
const Depsgraph *depsgraph,
const Material *material,
const bNode *node,
const bNodeSocket *socket_out,
NodeItem::Type to_type,
GroupNodeParser *group_parser,
bool use_group_default,
ExportImageFunction export_image_fn);
using GroupNodeParser::GroupNodeParser;
NodeItem compute() override;
NodeItem compute_full() override;

View File

@ -115,12 +115,12 @@ NodeItem NodeParser::get_input_default(int index, NodeItem::Type to_type)
NodeItem NodeParser::get_input_link(const std::string &name, NodeItem::Type to_type)
{
return get_input_link(node_->input_by_identifier(name), to_type);
return get_input_link(node_->input_by_identifier(name), to_type, false);
}
NodeItem NodeParser::get_input_link(int index, NodeItem::Type to_type)
{
return get_input_link(node_->input_socket(index), to_type);
return get_input_link(node_->input_socket(index), to_type, false);
}
NodeItem NodeParser::get_input_value(const std::string &name, NodeItem::Type to_type)
@ -227,7 +227,8 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket,
link->fromsock,
to_type,
group_parser_,
export_image_fn_)
export_image_fn_,
use_group_default)
.compute_full();
}
if (from_node->is_group_input()) {
@ -238,8 +239,8 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket,
link->fromsock,
to_type,
group_parser_,
use_group_default,
export_image_fn_)
export_image_fn_,
use_group_default)
.compute_full();
}

View File

@ -73,7 +73,7 @@ class NodeParser {
NodeItem get_default(const bNodeSocket &socket, NodeItem::Type to_type);
NodeItem get_input_link(const bNodeSocket &socket,
NodeItem::Type to_type,
bool use_group_default = false);
bool use_group_default);
NodeItem get_input_value(const bNodeSocket &socket, NodeItem::Type to_type);
};