forked from blender/blender
Fix linux build #33
@ -9,6 +9,21 @@
|
|||||||
|
|
||||||
namespace blender::nodes::materialx {
|
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 GroupNodeParser::compute()
|
||||||
{
|
{
|
||||||
NodeItem res = empty();
|
NodeItem res = empty();
|
||||||
@ -31,9 +46,15 @@ NodeItem GroupNodeParser::compute()
|
|||||||
graph = group_graph.get();
|
graph = group_graph.get();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NodeItem out =
|
NodeItem out = GroupOutputNodeParser(graph,
|
||||||
GroupOutputNodeParser(
|
depsgraph_,
|
||||||
graph, depsgraph_, material_, node_out, socket_out_, to_type_, this, export_image_fn_)
|
material_,
|
||||||
|
node_out,
|
||||||
|
socket_out_,
|
||||||
|
to_type_,
|
||||||
|
this,
|
||||||
|
export_image_fn_,
|
||||||
|
use_group_default_)
|
||||||
.compute_full();
|
.compute_full();
|
||||||
|
|
||||||
#ifdef USE_MATERIALX_NODEGRAPH
|
#ifdef USE_MATERIALX_NODEGRAPH
|
||||||
@ -74,7 +95,10 @@ NodeItem GroupOutputNodeParser::compute()
|
|||||||
}
|
}
|
||||||
return outputs[socket_out_->index()];
|
return outputs[socket_out_->index()];
|
||||||
#else
|
#else
|
||||||
|
if (use_group_default_) {
|
||||||
return get_input_value(socket_out_->index(), to_type_);
|
return get_input_value(socket_out_->index(), to_type_);
|
||||||
|
}
|
||||||
|
return get_input_link(socket_out_->index(), to_type_);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,21 +132,6 @@ std::string GroupOutputNodeParser::out_name(const bNodeSocket *out_socket)
|
|||||||
return MaterialX::createValidName(std::string("out_") + out_socket->name);
|
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()
|
NodeItem GroupInputNodeParser::compute()
|
||||||
{
|
{
|
||||||
#ifdef USE_MATERIALX_NODEGRAPH
|
#ifdef USE_MATERIALX_NODEGRAPH
|
||||||
|
@ -15,18 +15,28 @@ namespace blender::nodes::materialx {
|
|||||||
class GroupInputNodeParser;
|
class GroupInputNodeParser;
|
||||||
|
|
||||||
class GroupNodeParser : public NodeParser {
|
class GroupNodeParser : public NodeParser {
|
||||||
friend NodeParser;
|
|
||||||
friend GroupInputNodeParser;
|
friend GroupInputNodeParser;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool use_group_default_;
|
||||||
|
|
||||||
public:
|
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() override;
|
||||||
NodeItem compute_full() override;
|
NodeItem compute_full() override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupOutputNodeParser : public NodeParser {
|
class GroupOutputNodeParser : public GroupNodeParser {
|
||||||
public:
|
public:
|
||||||
using NodeParser::NodeParser;
|
using GroupNodeParser::GroupNodeParser;
|
||||||
NodeItem compute() override;
|
NodeItem compute() override;
|
||||||
NodeItem compute_full() override;
|
NodeItem compute_full() override;
|
||||||
|
|
||||||
@ -34,20 +44,9 @@ class GroupOutputNodeParser : public NodeParser {
|
|||||||
static std::string out_name(const bNodeSocket *out_socket);
|
static std::string out_name(const bNodeSocket *out_socket);
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupInputNodeParser : public NodeParser {
|
class GroupInputNodeParser : public GroupNodeParser {
|
||||||
private:
|
|
||||||
bool use_group_default_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GroupInputNodeParser(MaterialX::GraphElement *graph,
|
using GroupNodeParser::GroupNodeParser;
|
||||||
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);
|
|
||||||
NodeItem compute() override;
|
NodeItem compute() override;
|
||||||
NodeItem compute_full() override;
|
NodeItem compute_full() override;
|
||||||
|
|
||||||
|
@ -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)
|
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)
|
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)
|
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,
|
link->fromsock,
|
||||||
to_type,
|
to_type,
|
||||||
group_parser_,
|
group_parser_,
|
||||||
export_image_fn_)
|
export_image_fn_,
|
||||||
|
use_group_default)
|
||||||
.compute_full();
|
.compute_full();
|
||||||
}
|
}
|
||||||
if (from_node->is_group_input()) {
|
if (from_node->is_group_input()) {
|
||||||
@ -238,8 +239,8 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket,
|
|||||||
link->fromsock,
|
link->fromsock,
|
||||||
to_type,
|
to_type,
|
||||||
group_parser_,
|
group_parser_,
|
||||||
use_group_default,
|
export_image_fn_,
|
||||||
export_image_fn_)
|
use_group_default)
|
||||||
.compute_full();
|
.compute_full();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class NodeParser {
|
|||||||
NodeItem get_default(const bNodeSocket &socket, NodeItem::Type to_type);
|
NodeItem get_default(const bNodeSocket &socket, NodeItem::Type to_type);
|
||||||
NodeItem get_input_link(const bNodeSocket &socket,
|
NodeItem get_input_link(const bNodeSocket &socket,
|
||||||
NodeItem::Type to_type,
|
NodeItem::Type to_type,
|
||||||
bool use_group_default = false);
|
bool use_group_default);
|
||||||
NodeItem get_input_value(const bNodeSocket &socket, NodeItem::Type to_type);
|
NodeItem get_input_value(const bNodeSocket &socket, NodeItem::Type to_type);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user