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 */
#include "node_parser.h"
#include "group_nodes.h"
#include "node_parser.h"
#include "BLI_vector.hh"
@ -27,10 +27,14 @@ NodeItem GroupNodeParser::compute()
group_graph = graph_->addChild<MaterialX::NodeGraph>(name);
}
NodeItem out =
GroupOutputNodeParser(
group_graph.get(), depsgraph_, material_, node_out, socket_out_, NodeItem::Type::Any, this)
.compute_full();
NodeItem out = GroupOutputNodeParser(group_graph.get(),
depsgraph_,
material_,
node_out,
socket_out_,
NodeItem::Type::Any,
this)
.compute_full();
/* We have to be in NodeParser's graph_, therefore copying output */
res.output = out.output;
@ -55,6 +59,7 @@ NodeItem GroupOutputNodeParser::compute()
outputs.append(create_output("output" + std::to_string(i + 1), values[i]));
}
}
return outputs[socket_out_->index()];
}
@ -81,7 +86,14 @@ NodeItem GroupOutputNodeParser::compute_full()
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()
@ -89,8 +101,8 @@ NodeItem GroupInputNodeParser::compute_full()
NodeItem res = empty();
/* Checking if output was already computed */
res.output = graph_->getOutput("output" + std::to_string(socket_out_->index() + 1));
if (res.output) {
res.input = graph_->getInput("input" + std::to_string(socket_out_->index() + 1));
if (res.input) {
return res;
}