[Bf-blender-cvs] [ef89ba2b34d] temp-nodes-group-declarations: Merge branch 'master' into temp-nodes-group-declarations
Hans Goudey
noreply at git.blender.org
Thu Dec 29 22:31:29 CET 2022
Commit: ef89ba2b34d0f655090678073cfa019b9f9baa1a
Author: Hans Goudey
Date: Thu Dec 29 15:40:18 2022 -0500
Branches: temp-nodes-group-declarations
https://developer.blender.org/rBef89ba2b34d0f655090678073cfa019b9f9baa1a
Merge branch 'master' into temp-nodes-group-declarations
===================================================================
===================================================================
diff --cc source/blender/nodes/NOD_node_declaration.hh
index d549263f036,7753e8092d8..934e44ceed8
--- a/source/blender/nodes/NOD_node_declaration.hh
+++ b/source/blender/nodes/NOD_node_declaration.hh
@@@ -72,25 -72,24 +72,25 @@@ using ImplicitInputValueFn = std::funct
*/
class SocketDeclaration {
public:
- std::string name_;
- std::string identifier_;
- std::string description_;
-
+ std::string name;
+ std::string identifier;
+ std::string description;
/** Defined by whether the socket is part of the node's input or
* output socket declaration list. Included here for convenience. */
- eNodeSocketInOut in_out_;
- bool hide_label_ = false;
- bool hide_value_ = false;
- bool compact_ = false;
- bool is_multi_input_ = false;
- bool no_mute_links_ = false;
- bool is_unavailable_ = false;
- bool is_attribute_name_ = false;
- bool is_default_link_socket_ = false;
-
- InputSocketFieldType input_field_type_ = InputSocketFieldType::None;
- OutputFieldDependency output_field_dependency_;
+ eNodeSocketInOut in_out;
+ bool hide_label = false;
+ bool hide_value = false;
+ bool compact = false;
+ bool is_multi_input = false;
+ bool no_mute_links = false;
+ bool is_unavailable = false;
+ bool is_attribute_name = false;
+ bool is_default_link_socket = false;
+
+ InputSocketFieldType input_field_type = InputSocketFieldType::None;
+ OutputFieldDependency output_field_dependency;
++ private:
/** The priority of the input for determining the domain of the node. See
* realtime_compositor::InputDescriptor for more information. */
int compositor_domain_priority_ = 0;
@@@ -308,21 -297,12 +298,17 @@@ using SocketDeclarationPtr = std::uniqu
class NodeDeclaration {
public:
- Vector<SocketDeclarationPtr> inputs_;
- Vector<SocketDeclarationPtr> outputs_;
+ Vector<SocketDeclarationPtr> inputs;
+ Vector<SocketDeclarationPtr> outputs;
+ /** Leave the sockets in place, even if they don't match the declaration. Used for dynamic
+ * declarations when the information used to build the declaration is missing, but might become
+ * available again in the future. */
+ bool skip_updating_sockets = false;
+
friend NodeDeclarationBuilder;
- public:
bool matches(const bNode &node) const;
-
- Span<SocketDeclarationPtr> inputs() const;
- Span<SocketDeclarationPtr> outputs() const;
Span<SocketDeclarationPtr> sockets(eNodeSocketInOut in_out) const;
MEM_CXX_CLASS_ALLOC_FUNCS("NodeDeclaration")
diff --cc source/blender/nodes/intern/node_common.cc
index 286a28625cd,509921837cc..71ca2f0dab6
--- a/source/blender/nodes/intern/node_common.cc
+++ b/source/blender/nodes/intern/node_common.cc
@@@ -124,120 -120,122 +124,120 @@@ bool nodeGroupPoll(const bNodeTree *nod
return true;
}
-static void add_new_socket_from_interface(bNodeTree &node_tree,
- bNode &node,
- const bNodeSocket &interface_socket,
- const eNodeSocketInOut in_out)
-{
- bNodeSocket *socket = nodeAddSocket(&node_tree,
- &node,
- in_out,
- interface_socket.idname,
- interface_socket.identifier,
- interface_socket.name);
-
- if (interface_socket.typeinfo->interface_init_socket) {
- interface_socket.typeinfo->interface_init_socket(
- &node_tree, &interface_socket, &node, socket, "interface");
- }
-}
+namespace blender::nodes {
-static void update_socket_to_match_interface(bNodeTree &node_tree,
- bNode &node,
- bNodeSocket &socket_to_update,
- const bNodeSocket &interface_socket)
+static SocketDeclarationPtr declaration_for_interface_socket(const bNodeSocket &io_socket)
{
- strcpy(socket_to_update.name, interface_socket.name);
-
- const int mask = SOCK_HIDE_VALUE;
- socket_to_update.flag = (socket_to_update.flag & ~mask) | (interface_socket.flag & mask);
-
- /* Update socket type if necessary */
- if (socket_to_update.typeinfo != interface_socket.typeinfo) {
- nodeModifySocketType(&node_tree, &node, &socket_to_update, interface_socket.idname);
- }
-
- if (interface_socket.typeinfo->interface_verify_socket) {
- interface_socket.typeinfo->interface_verify_socket(
- &node_tree, &interface_socket, &node, &socket_to_update, "interface");
- }
-}
-
-/**
- * Used for group nodes and group input/output nodes to update the list of input or output sockets
- * on a node to match the provided interface. Assumes that \a verify_lb is the node's matching
- * input or output socket list, depending on whether the node is a group input/output or a group
- * node.
- */
-static void group_verify_socket_list(bNodeTree &node_tree,
- bNode &node,
- const ListBase &interface_sockets,
- ListBase &verify_lb,
- const eNodeSocketInOut in_out,
- const bool ensure_extend_socket_exists)
-{
- ListBase old_sockets = verify_lb;
- Vector<bNodeSocket *> ordered_old_sockets = old_sockets;
- BLI_listbase_clear(&verify_lb);
-
- LISTBASE_FOREACH (const bNodeSocket *, interface_socket, &interface_sockets) {
- bNodeSocket *matching_socket = find_matching_socket(old_sockets, interface_socket->identifier);
- if (matching_socket) {
- /* If a socket with the same identifier exists in the previous socket list, update it
- * with the correct name, type, etc. Then move it from the old list to the new one. */
- update_socket_to_match_interface(node_tree, node, *matching_socket, *interface_socket);
- BLI_remlink(&old_sockets, matching_socket);
- BLI_addtail(&verify_lb, matching_socket);
+ SocketDeclarationPtr dst;
+ switch (io_socket.type) {
+ case SOCK_FLOAT: {
+ const auto &value = *io_socket.default_value_typed<bNodeSocketValueFloat>();
+ std::unique_ptr<decl::Float> decl = std::make_unique<decl::Float>();
+ decl->subtype = PropertySubType(io_socket.typeinfo->subtype);
+ decl->default_value = value.value;
+ decl->soft_min_value = value.min;
+ decl->soft_max_value = value.max;
+ dst = std::move(decl);
+ break;
}
- else {
- /* If there was no socket with the same identifier already, simply create a new socket
- * based on the interface socket, which will already add it to the new list. */
- add_new_socket_from_interface(node_tree, node, *interface_socket, in_out);
+ case SOCK_VECTOR: {
+ const auto &value = *io_socket.default_value_typed<bNodeSocketValueVector>();
+ std::unique_ptr<decl::Vector> decl = std::make_unique<decl::Vector>();
+ decl->subtype = PropertySubType(io_socket.typeinfo->subtype);
+ decl->default_value = value.value;
+ decl->soft_min_value = value.min;
+ decl->soft_max_value = value.max;
+ dst = std::move(decl);
+ break;
}
- }
-
- if (ensure_extend_socket_exists) {
- bNodeSocket *last_socket = static_cast<bNodeSocket *>(old_sockets.last);
- if (last_socket != nullptr && STREQ(last_socket->identifier, "__extend__")) {
- BLI_remlink(&old_sockets, last_socket);
- BLI_addtail(&verify_lb, last_socket);
+ case SOCK_RGBA: {
+ const auto &value = *io_socket.default_value_typed<bNodeSocketValueRGBA>();
+ std::unique_ptr<decl::Color> decl = std::make_unique<decl::Color>();
+ decl->default_value = value.value;
+ dst = std::move(decl);
+ break;
}
- else {
- nodeAddSocket(&node_tree, &node, in_out, "NodeSocketVirtual", "__extend__", "");
+ case SOCK_SHADER: {
+ std::unique_ptr<decl::Shader> decl = std::make_unique<decl::Shader>();
+ dst = std::move(decl);
+ break;
}
- }
-
- /* Remove leftover sockets that didn't match the node group's interface. */
- LISTBASE_FOREACH_MUTABLE (bNodeSocket *, unused_socket, &old_sockets) {
- nodeRemoveSocket(&node_tree, &node, unused_socket);
- }
-
- {
- /* Check if new sockets match the old sockets. */
- int index;
- LISTBASE_FOREACH_INDEX (bNodeSocket *, new_socket, &verify_lb, index) {
- if (index < ordered_old_sockets.size()) {
- if (ordered_old_sockets[index] != new_socket) {
- BKE_ntree_update_tag_interface(&node_tree);
- break;
- }
- }
+ case SOCK_BOOLEAN: {
+ const auto &value = *io_socket.default_value_typed<bNodeSocketValueBoolean>();
+ std::unique_ptr<decl::Bool> decl = std::make_unique<decl::Bool>();
+ decl->default_value = value.value;
+ dst = std::move(decl);
+ break;
}
+ case SOCK_INT: {
+ const auto &value = *io_socket.default_value_typed<bNodeSocketValueInt>();
+ std::unique_ptr<decl::Int> decl = std::make_unique<decl::Int>();
+ decl->subtype = PropertySubType(io_socket.typeinfo->subtype);
+ decl->default_value = value.value;
+ decl->soft_min_value = value.min;
+ decl->soft_max_value = value.max;
+ dst = std::move(decl);
+ break;
+ }
+ case SOCK_STRING: {
+ const auto &value = *io_socket.default_value_typed<bNodeSocketValueString>();
+ std::unique_ptr<decl::String> decl = std::make_unique<decl::String>();
+ decl->default_value = value.value;
+ dst = std::move(decl);
+ break;
+ }
+ case SOCK_OBJECT:
+ dst = std::make_unique<decl::Object>();
+ break;
+ case SOCK_IMAGE:
+ dst = std::make_unique<decl::Image>();
+ break;
+ case SOCK_GEOMETRY:
+ dst = std::make_unique<decl::Geometry>();
+ break;
+ case SOCK_COLLECTION:
+ dst = std::make_unique<decl::Collection>();
+ break;
+ case SOCK_TEXTURE:
+ dst = std::make_unique<decl::T
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list