Blender V5.3
NOD_socket_usage_inference.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include <optional>
12
13#include "BLI_array.hh"
15
16#include "BKE_node.hh"
17
21
22namespace blender {
23
24struct bNodeTree;
25struct bNodeSocket;
26struct IDProperty;
27
29
31
36 private:
38
39 friend class SocketUsageParams;
40
41 public:
43 ResourceScope &scope,
44 SocketValueInferencer &value_inferencer,
45 bke::ComputeContextCache &compute_context_cache,
46 bool ignore_top_level_node_muting = false);
47
48 bool is_socket_used(const SocketInContext &socket);
49 bool is_group_input_used(int input_i);
50
51 bool is_disabled_output(const SocketInContext &socket);
52 bool is_disabled_group_output(int output_i);
53
59};
60
62 private:
63 SocketUsageInferencer &inferencer_;
64 const ComputeContext *compute_context_ = nullptr;
65
66 public:
68 const bNode &node;
70
72 const ComputeContext *compute_context,
73 const bNodeTree &tree,
74 const bNode &node,
75 const bNodeSocket &socket);
76
81 InferenceValue get_input(UString identifier) const;
82
88 std::optional<bool> any_output_is_used() const;
89
93 bool menu_input_may_be(UString identifier, int enum_value) const;
94 bool bool_input_may_be(UString identifier, bool bool_value) const;
95};
96
102
115 const bNodeTree &group,
116 Span<InferenceValue> group_input_values,
117 MutableSpan<SocketUsage> r_input_usages,
118 std::optional<MutableSpan<SocketUsage>> r_output_usages = std::nullopt);
119
125 Span<const bNodeSocket *> input_sockets,
126 MutableSpan<SocketUsage> r_input_usages);
127
133 const bNodeTree &group,
134 const PointerRNA &properties_ptr,
135 MutableSpan<SocketUsage> r_input_usages,
136 std::optional<MutableSpan<SocketUsage>> r_output_usages = std::nullopt);
137
138} // namespace nodes::socket_usage_inference
139
140} // namespace blender
SocketUsageInferencer(const bNodeTree &tree, ResourceScope &scope, SocketValueInferencer &value_inferencer, bke::ComputeContextCache &compute_context_cache, bool ignore_top_level_node_muting=false)
SocketUsageParams(SocketUsageInferencer &inferencer, const ComputeContext *compute_context, const bNodeTree &tree, const bNode &node, const bNodeSocket &socket)
bool bool_input_may_be(UString identifier, bool bool_value) const
bool menu_input_may_be(UString identifier, int enum_value) const
Array< SocketUsage > infer_all_sockets_usage(const bNodeTree &tree)
void infer_group_interface_inputs_usage(const bNodeTree &group, Span< const bNodeSocket * > input_sockets, MutableSpan< SocketUsage > r_input_usages)
void infer_group_interface_usage(const bNodeTree &group, const Span< InferenceValue > group_input_values, const MutableSpan< SocketUsage > r_input_usages, const std::optional< MutableSpan< SocketUsage > > r_output_usages)
BMesh Iterators.