forked from blender/blender
matx-code-improvements #8
@ -79,11 +79,6 @@ void NodeItem::add_output(const std::string &name, const std::string &mx_type)
|
||||
node->addOutput(name, mx_type);
|
||||
}
|
||||
|
||||
void NodeItem::set_name(const std::string &name)
|
||||
{
|
||||
node->setName(MaterialX::createValidName(name));
|
||||
}
|
||||
|
||||
NodeItem::operator bool() const
|
||||
{
|
||||
return value || node;
|
||||
|
@ -33,7 +33,6 @@ class NodeItem {
|
||||
const MaterialX::NodePtr node,
|
||||
const std::string &output_name = "");
|
||||
void add_output(const std::string &name, const std::string &mx_type);
|
||||
void set_name(const std::string &name);
|
||||
|
||||
operator bool() const;
|
||||
NodeItem operator+(const NodeItem &other) const;
|
||||
|
@ -60,6 +60,13 @@ NodeItem NodeParser::empty() const
|
||||
return NodeItem(graph_);
|
||||
}
|
||||
|
||||
std::string NodeParser::node_name(const bNode *node, const bNodeSocket *socket_out)
|
||||
{
|
||||
return MaterialX::createValidName(node->output_sockets().size() == 1 ?
|
||||
std::string(node->name) :
|
||||
std::string(node->name) + "_" + socket_out->name);
|
||||
}
|
||||
|
||||
NodeItem NodeParser::get_input_default(const bNodeSocket &socket)
|
||||
{
|
||||
NodeItem res = empty();
|
||||
@ -105,6 +112,12 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket)
|
||||
from_node = link->fromnode;
|
||||
}
|
||||
|
||||
/* Checking if node was already computed */
|
||||
res.node = graph_->getNode(node_name(from_node, link->fromsock));
|
||||
if (res.node) {
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Computing from_node with required NodeParser object */
|
||||
#define CASE_NODE_TYPE(type, T) \
|
||||
case type: \
|
||||
@ -126,7 +139,6 @@ NodeItem NodeParser::get_input_link(const bNodeSocket &socket)
|
||||
"Unsupported node: %s [%d]",
|
||||
from_node->name,
|
||||
from_node->typeinfo->type);
|
||||
return res;
|
||||
}
|
||||
|
||||
return res;
|
||||
@ -146,9 +158,7 @@ NodeItem NodeParser::compute_full()
|
||||
CLOG_INFO(LOG_MATERIALX_SHADER, 1, "%s [%d]", node_->name, node_->typeinfo->type);
|
||||
NodeItem res = compute();
|
||||
if (res.node) {
|
||||
res.set_name(node_->output_sockets().size() == 1 ?
|
||||
std::string(node_->name) :
|
||||
std::string(node_->name) + "_" + socket_out_->name);
|
||||
res.node->setName(node_name(node_, socket_out_));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -41,6 +41,7 @@ class NodeParser {
|
||||
template<class T> NodeItem value(const T &data) const;
|
||||
|
||||
private:
|
||||
static std::string node_name(const bNode *node, const bNodeSocket *socket_out);
|
||||
NodeItem get_input_default(const bNodeSocket &socket);
|
||||
NodeItem get_input_link(const bNodeSocket &socket);
|
||||
NodeItem get_input_value(const bNodeSocket &socket);
|
||||
|
Loading…
Reference in New Issue
Block a user