Previously, the right sockets were already created on closure/bundle nodes when link-drag-search is used. However, after initialization, there was no automatic way to synchronize the sockets again after changes to one of the nodes. Instead one had to copy the changes manually. This patch adds a new operator that can automatically update the sockets on the following nodes based on what is connected: Combine Bundle, Separate Bundle, Closure (zone), Evaluate Closure. The button is always visible in the side bar. In the future we may also want to show it inside of the node when syncing is necessary. However, that's not done in this patch. It's also a little bit tricky because detecting whether syncing is necessary is not necessarily cheap (it requires traversing the tree including going into nested node groups). If no signature or conflicting signatures for the bundle or closure are found, the operator does nothing. In this case, the user is currently responsible to create/remove the sockets manually. Pull Request: https://projects.blender.org/blender/blender/pulls/140449
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
/* SPDX-FileCopyrightText: 2025 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include "BLI_vector.hh"
|
|
|
|
namespace blender::nodes {
|
|
|
|
/**
|
|
* A key that identifies values in a bundle or inputs/outputs of a closure.
|
|
* Note that this key does not have a hash and thus can't be used in a hash table. This wouldn't
|
|
* work well if these items have multiple identifiers for compatibility reasons. While that's not
|
|
* used currently, it's good to keep it possible.
|
|
*/
|
|
class SocketInterfaceKey {
|
|
private:
|
|
/** May have multiple keys to improve compatibility between systems that use different keys. */
|
|
Vector<std::string> identifiers_;
|
|
|
|
public:
|
|
explicit SocketInterfaceKey(Vector<std::string> identifiers);
|
|
explicit SocketInterfaceKey(std::string identifier);
|
|
|
|
/** Two keys match when they have one common identifier. */
|
|
bool matches(const SocketInterfaceKey &other) const;
|
|
/** Two keys match exactly when the have the same identifiers (the order doesn't matter). */
|
|
bool matches_exactly(const SocketInterfaceKey &other) const;
|
|
|
|
Span<std::string> identifiers() const;
|
|
};
|
|
|
|
} // namespace blender::nodes
|