Files
test/source/blender/nodes/NOD_geometry_nodes_closure_signature.hh
Jacques Lucke 60a416bea4 Geometry Nodes: improve socket shapes for bundle and closure nodes
Previously, the closure and bundle nodes were a bit restrictive when it comes to
socket shapes. Especially the bundle nodes did not support customizing the
socket shape at all, so they always worked with dynamic values. This was
problematic, because it meant that e.g. the outputs of the Separate Bundle node
looked like they couldn't be used as single values, and other similar issues.

With this patch, the following is supported (a few aspects were supported before
but now it all fits better together): * Support manually selecting socket shapes
in Combine Bundle, Separate Bundle, Closure Input, Closure Output and Evaluate
Closure nodes. * Automatic inferencing of shapes in all these nodes, as long as
the socket shape is set to "auto". * A new "Define Signature" option can be
enabled in the nodes. If enabled, linked nodes will also sync the socket shapes
from that node. In the future, we also want to add support for naming the
signature.

Pull Request: https://projects.blender.org/blender/blender/pulls/145550
2025-09-27 14:58:43 +02:00

66 lines
1.8 KiB
C++

/* SPDX-FileCopyrightText: 2025 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma once
#include "BKE_node.hh"
#include "BLI_vector_set.hh"
#include "NOD_node_in_compute_context.hh"
namespace blender::nodes {
/** Describes the names and types of the inputs and outputs of a closure. */
class ClosureSignature {
public:
struct Item {
std::string key;
const bke::bNodeSocketType *type = nullptr;
NodeSocketInterfaceStructureType structure_type;
BLI_STRUCT_EQUALITY_OPERATORS_3(Item, key, type, structure_type);
};
struct ItemKeyGetter {
std::string operator()(const Item &item)
{
return item.key;
}
};
CustomIDVectorSet<Item, ItemKeyGetter> inputs;
CustomIDVectorSet<Item, ItemKeyGetter> outputs;
std::optional<int> find_input_index(StringRef key) const;
std::optional<int> find_output_index(StringRef key) const;
friend bool operator==(const ClosureSignature &a, const ClosureSignature &b);
friend bool operator!=(const ClosureSignature &a, const ClosureSignature &b);
static ClosureSignature from_closure_output_node(const bNode &node,
bool allow_auto_structure_type);
static ClosureSignature from_evaluate_closure_node(const bNode &node,
bool allow_auto_structure_type);
void set_auto_structure_types();
};
/**
* Multiple closure signatures that may be linked to a single node.
*/
struct LinkedClosureSignatures {
struct Item {
ClosureSignature signature;
bool define_signature = false;
SocketInContext socket;
};
Vector<Item> items;
bool has_type_definition() const;
std::optional<ClosureSignature> get_merged_signature() const;
};
} // namespace blender::nodes