Support group nodes #22

Merged
Bogdan Nagirniak merged 18 commits from BogdanNagirniak/blender:matx-group-nodes into matx-export-material 2023-09-18 12:49:19 +02:00
Showing only changes of commit 8f67ebb007 - Show all commits

View File

@ -2,8 +2,8 @@
* *
* SPDX-License-Identifier: GPL-2.0-or-later */ * SPDX-License-Identifier: GPL-2.0-or-later */
#include "node_parser.h"
#include "group_nodes.h" #include "group_nodes.h"
#include "node_parser.h"
#include "BLI_vector.hh" #include "BLI_vector.hh"
@ -27,9 +27,13 @@ NodeItem GroupNodeParser::compute()
group_graph = graph_->addChild<MaterialX::NodeGraph>(name); group_graph = graph_->addChild<MaterialX::NodeGraph>(name);
} }
NodeItem out = NodeItem out = GroupOutputNodeParser(group_graph.get(),
GroupOutputNodeParser( depsgraph_,
group_graph.get(), depsgraph_, material_, node_out, socket_out_, NodeItem::Type::Any, this) material_,
node_out,
socket_out_,
NodeItem::Type::Any,
this)
.compute_full(); .compute_full();
/* We have to be in NodeParser's graph_, therefore copying output */ /* We have to be in NodeParser's graph_, therefore copying output */
@ -55,6 +59,7 @@ NodeItem GroupOutputNodeParser::compute()
outputs.append(create_output("output" + std::to_string(i + 1), values[i])); outputs.append(create_output("output" + std::to_string(i + 1), values[i]));
} }
} }
return outputs[socket_out_->index()]; return outputs[socket_out_->index()];
} }
@ -81,7 +86,14 @@ NodeItem GroupOutputNodeParser::compute_full()
NodeItem GroupInputNodeParser::compute() NodeItem GroupInputNodeParser::compute()
{ {
return group_parser_->get_input_default(socket_out_->index(), to_type_); NodeItem value = group_parser_->get_input_value(socket_out_->index(), to_type_);
if (value.value) {
NodeItem constant = create_node("constant", value.type());
constant.set_input("value", value);
value = constant;
}
return create_input("input" + std::to_string(socket_out_->index() + 1), value);
} }
NodeItem GroupInputNodeParser::compute_full() NodeItem GroupInputNodeParser::compute_full()
@ -89,8 +101,8 @@ NodeItem GroupInputNodeParser::compute_full()
NodeItem res = empty(); NodeItem res = empty();
/* Checking if output was already computed */ /* Checking if output was already computed */
res.output = graph_->getOutput("output" + std::to_string(socket_out_->index() + 1)); res.input = graph_->getInput("input" + std::to_string(socket_out_->index() + 1));
if (res.output) { if (res.input) {
return res; return res;
} }