Blender V5.3
node_graph.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include <string>
8
9#include <MaterialXCore/Document.h>
10
11#include "material.h"
12#include "node_item.h"
13
14#include "BLI_map.hh"
15#include "BLI_set.hh"
16#include "BLI_string_ref.hh"
17
18namespace blender {
19
20struct Depsgraph;
21struct bNode;
22struct Material;
23namespace nodes::materialx {
24
25/*
26 * Wrapper around MaterialX graph.
27 */
28struct NodeGraph {
29 public:
30 const Depsgraph *depsgraph = nullptr;
31 const Material *material = nullptr;
33
34 NodeGraph(const Depsgraph *depsgraph,
35 const Material *material,
37 const MaterialX::DocumentPtr &document);
38 NodeGraph(const NodeGraph &parent, StringRef child_name);
39
40 NodeItem empty_node() const;
41 NodeItem get_node(StringRef name) const;
42 NodeItem get_output(StringRef name) const;
43 NodeItem get_input(StringRef name) const;
44
45 std::string unique_node_name(const bNode *node,
46 StringRef socket_out_name,
48 void set_output_node_name(const NodeItem &item) const;
49
50 static std::string unique_anonymous_node_name(MaterialX::GraphElement *graph_element);
51
52 protected:
53 struct NodeKey {
54 const bNode *node;
55 std::string socket_name;
57 MaterialX::GraphElement *graph_element;
58
59 uint64_t hash() const;
60 bool operator==(const NodeKey &other) const;
61 };
62
63 MaterialX::GraphElement *graph_element_ = nullptr;
67 std::string node_name_prefix_;
68};
69
70} // namespace nodes::materialx
71} // namespace blender
uint to_type(bool)
BMesh Iterators.
unsigned __int64 uint64_t
Definition BKE_text.h:91
MaterialX::GraphElement * graph_element
Definition node_graph.h:57
bool operator==(const NodeKey &other) const
Definition node_graph.cc:44
void set_output_node_name(const NodeItem &item) const
NodeItem get_node(StringRef name) const
Definition node_graph.cc:95
std::string unique_node_name(const bNode *node, StringRef socket_out_name, NodeItem::Type to_type)
static std::string unique_anonymous_node_name(MaterialX::GraphElement *graph_element)
Map< NodeKey, const std::string > root_key_to_name_map_
Definition node_graph.h:64
NodeItem get_input(StringRef name) const
const ExportParams & export_params
Definition node_graph.h:32
Map< NodeKey, const std::string > & key_to_name_map_
Definition node_graph.h:65
NodeItem get_output(StringRef name) const
Set< std::string > used_node_names_
Definition node_graph.h:66
NodeGraph(const Depsgraph *depsgraph, const Material *material, const ExportParams &export_params, const MaterialX::DocumentPtr &document)
Definition node_graph.cc:52
MaterialX::GraphElement * graph_element_
Definition node_graph.h:63