matx-extend-create_node #25

Merged
Bogdan Nagirniak merged 4 commits from BogdanNagirniak/blender:matx-extend-create_node into matx-export-material 2023-09-19 18:28:04 +02:00
4 changed files with 8 additions and 8 deletions
Showing only changes of commit e40e47d374 - Show all commits

View File

@ -626,7 +626,7 @@ NodeItem::Type NodeItem::type() const
return Type::Empty; return Type::Empty;
} }
NodeItem NodeItem::create_node(const std::string &category, NodeItem::Type type) const NodeItem NodeItem::create_node(const std::string &category, Type type) const
{ {
std::string type_str = this->type(type); std::string type_str = this->type(type);
CLOG_INFO(LOG_MATERIALX_SHADER, 2, "<%s type=%s>", category.c_str(), type_str.c_str()); CLOG_INFO(LOG_MATERIALX_SHADER, 2, "<%s type=%s>", category.c_str(), type_str.c_str());
@ -635,9 +635,7 @@ NodeItem NodeItem::create_node(const std::string &category, NodeItem::Type type)
return res; return res;
} }
NodeItem NodeItem::create_node(const std::string &category, NodeItem NodeItem::create_node(const std::string &category, Type type, const Inputs &inputs) const
NodeItem::Type type,
const std::map<std::string, NodeItem> &inputs) const
{ {
NodeItem res = create_node(category, type); NodeItem res = create_node(category, type);
for (auto &it : inputs) { for (auto &it : inputs) {

View File

@ -15,6 +15,8 @@ namespace blender::nodes::materialx {
* All work should be done via this class instead of using MaterialX API directly. */ * All work should be done via this class instead of using MaterialX API directly. */
class NodeItem { class NodeItem {
public: public:
using Inputs = std::vector<std::pair<std::string, NodeItem>>;
enum class Type { enum class Type {
Any = 0, Any = 0,
Empty, Empty,
@ -108,8 +110,8 @@ class NodeItem {
Type type() const; Type type() const;
/* Node functions */ /* Node functions */
NodeItem create_node(const std::string &category, NodeItem::Type type) const; NodeItem create_node(const std::string &category, Type type) const;
NodeItem create_node(const std::string &category, NodeItem::Type type, const std::map<std::string, NodeItem> &inputs) const; NodeItem create_node(const std::string &category, Type type, const Inputs &inputs) const;
template<class T> void set_input(const std::string &in_name, const T &value, Type in_type); template<class T> void set_input(const std::string &in_name, const T &value, Type in_type);
void set_input(const std::string &in_name, const NodeItem &item); void set_input(const std::string &in_name, const NodeItem &item);
NodeItem add_output(const std::string &out_name, Type out_type); NodeItem add_output(const std::string &out_name, Type out_type);

View File

@ -86,7 +86,7 @@ NodeItem NodeParser::create_node(const std::string &category, NodeItem::Type typ
NodeItem NodeParser::create_node(const std::string &category, NodeItem NodeParser::create_node(const std::string &category,
NodeItem::Type type, NodeItem::Type type,
const std::map<std::string, NodeItem> &inputs) const NodeItem::Inputs &inputs)
{ {
return empty().create_node(category, type, inputs); return empty().create_node(category, type, inputs);
} }

View File

@ -46,7 +46,7 @@ class NodeParser {
NodeItem create_node(const std::string &category, NodeItem::Type type); NodeItem create_node(const std::string &category, NodeItem::Type type);
NodeItem create_node(const std::string &category, NodeItem create_node(const std::string &category,
NodeItem::Type type, NodeItem::Type type,
const std::map<std::string, NodeItem> &inputs); const NodeItem::Inputs &inputs);
NodeItem create_input(const std::string &name, const NodeItem &item); NodeItem create_input(const std::string &name, const NodeItem &item);
NodeItem create_output(const std::string &name, const NodeItem &item); NodeItem create_output(const std::string &name, const NodeItem &item);
NodeItem get_input_default(const std::string &name, NodeItem::Type to_type); NodeItem get_input_default(const std::string &name, NodeItem::Type to_type);