Blender V5.0
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
18struct bNode;
19struct Material;
20struct Depsgraph;
21
23
24/*
25 * Wrapper around MaterialX graph.
26 */
27struct NodeGraph {
28 public:
29 const Depsgraph *depsgraph = nullptr;
30 const Material *material = nullptr;
32
33 NodeGraph(const Depsgraph *depsgraph,
34 const Material *material,
36 const MaterialX::DocumentPtr &document);
37 NodeGraph(const NodeGraph &parent, StringRef child_name);
38
39 NodeItem empty_node() const;
43
44 std::string unique_node_name(const bNode *node,
45 StringRef socket_out_name,
47 void set_output_node_name(const NodeItem &item) const;
48
49 static std::string unique_anonymous_node_name(MaterialX::GraphElement *graph_element);
50
51 protected:
52 struct NodeKey {
53 const bNode *node;
54 std::string socket_name;
56 MaterialX::GraphElement *graph_element;
57
58 uint64_t hash() const;
59 bool operator==(const NodeKey &other) const;
60 };
61
62 MaterialX::GraphElement *graph_element_ = nullptr;
66 std::string node_name_prefix_;
67};
68
69} // namespace blender::nodes::materialx
unsigned long long int uint64_t
static Type to_type(const GPUType type)
const char * name
MaterialX::GraphElement * graph_element
Definition node_graph.h:56
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:63
NodeItem get_input(StringRef name) const
const ExportParams & export_params
Definition node_graph.h:31
Map< NodeKey, const std::string > & key_to_name_map_
Definition node_graph.h:64
NodeItem get_output(StringRef name) const
Set< std::string > used_node_names_
Definition node_graph.h:65
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:62