Blender V5.0
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
5#pragma once
6
7#include <optional>
8
9#include "BLI_array.hh"
11
12#include "BKE_node.hh"
13
17
18struct bNodeTree;
19struct bNodeSocket;
20struct IDProperty;
21
23
25
30 private:
32
34
35 public:
37 ResourceScope &scope,
38 SocketValueInferencer &value_inferencer,
39 bke::ComputeContextCache &compute_context_cache,
40 bool ignore_top_level_node_muting = false);
41
42 bool is_socket_used(const SocketInContext &socket);
43 bool is_group_input_used(int input_i);
44
45 bool is_disabled_output(const SocketInContext &socket);
46 bool is_disabled_group_output(int output_i);
47
52};
53
55 private:
56 SocketUsageInferencer &inferencer_;
57 const ComputeContext *compute_context_ = nullptr;
58
59 public:
61 const bNode &node;
63
65 const ComputeContext *compute_context,
66 const bNodeTree &tree,
67 const bNode &node,
68 const bNodeSocket &socket);
69
74 InferenceValue get_input(StringRef identifier) const;
75
81 std::optional<bool> any_output_is_used() const;
82
86 bool menu_input_may_be(StringRef identifier, int enum_value) const;
87};
88
94
107 const bNodeTree &group,
108 Span<InferenceValue> group_input_values,
109 MutableSpan<SocketUsage> r_input_usages,
110 std::optional<MutableSpan<SocketUsage>> r_output_usages = std::nullopt);
111
117 Span<const bNodeSocket *> input_sockets,
118 MutableSpan<SocketUsage> r_input_usages);
119
125 const bNodeTree &group,
126 const IDProperty *properties,
127 MutableSpan<SocketUsage> r_input_usages,
128 std::optional<MutableSpan<SocketUsage>> r_output_usages = std::nullopt);
129
130} // namespace blender::nodes::socket_usage_inference
bool menu_input_may_be(StringRef identifier, int enum_value) const
InputSocketUsageParams(SocketUsageInferencer &inferencer, const ComputeContext *compute_context, const bNodeTree &tree, const bNode &node, const bNodeSocket &socket)
SocketUsageInferencer(const bNodeTree &tree, ResourceScope &scope, SocketValueInferencer &value_inferencer, bke::ComputeContextCache &compute_context_cache, bool ignore_top_level_node_muting=false)
KDTree_3d * tree
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)