[Bf-blender-cvs] [844b3ed472d] temp-nodes-group-declarations: Fix various issues in socket declaration updating/building/comparison
Hans Goudey
noreply at git.blender.org
Mon Jan 2 22:07:02 CET 2023
Commit: 844b3ed472d21c20fe460001098d31b5f8e31dc7
Author: Hans Goudey
Date: Mon Jan 2 16:06:54 2023 -0500
Branches: temp-nodes-group-declarations
https://developer.blender.org/rB844b3ed472d21c20fe460001098d31b5f8e31dc7
Fix various issues in socket declaration updating/building/comparison
===================================================================
M source/blender/nodes/NOD_socket_declarations.hh
M source/blender/nodes/intern/node_socket_declarations.cc
===================================================================
diff --git a/source/blender/nodes/NOD_socket_declarations.hh b/source/blender/nodes/NOD_socket_declarations.hh
index c45dbd878d2..4c4b1afbcca 100644
--- a/source/blender/nodes/NOD_socket_declarations.hh
+++ b/source/blender/nodes/NOD_socket_declarations.hh
@@ -104,6 +104,7 @@ class Bool : public SocketDeclaration {
bNodeSocket &build(bNodeTree &ntree, bNode &node) const override;
bool matches(const bNodeSocket &socket) const override;
+ bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override;
bool can_connect(const bNodeSocket &socket) const override;
};
@@ -124,6 +125,7 @@ class Color : public SocketDeclaration {
bNodeSocket &build(bNodeTree &ntree, bNode &node) const override;
bool matches(const bNodeSocket &socket) const override;
+ bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override;
bool can_connect(const bNodeSocket &socket) const override;
};
@@ -144,6 +146,7 @@ class String : public SocketDeclaration {
bNodeSocket &build(bNodeTree &ntree, bNode &node) const override;
bool matches(const bNodeSocket &socket) const override;
+ bNodeSocket &update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const override;
bool can_connect(const bNodeSocket &socket) const override;
};
diff --git a/source/blender/nodes/intern/node_socket_declarations.cc b/source/blender/nodes/intern/node_socket_declarations.cc
index 2cdfc9a6928..5fd4c4aad0d 100644
--- a/source/blender/nodes/intern/node_socket_declarations.cc
+++ b/source/blender/nodes/intern/node_socket_declarations.cc
@@ -234,6 +234,14 @@ bool Vector::matches(const bNodeSocket &socket) const
if (socket.typeinfo->subtype != this->subtype) {
return false;
}
+ const bNodeSocketValueVector &value = *static_cast<const bNodeSocketValueVector *>(
+ socket.default_value);
+ if (value.min != this->soft_min_value) {
+ return false;
+ }
+ if (value.max != this->soft_max_value) {
+ return false;
+ }
return true;
}
@@ -257,6 +265,8 @@ bNodeSocket &Vector::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket
this->set_common_flags(socket);
bNodeSocketValueVector &value = *(bNodeSocketValueVector *)socket.default_value;
value.subtype = this->subtype;
+ value.min = this->soft_min_value;
+ value.max = this->soft_max_value;
STRNCPY(socket.name, this->name.c_str());
return socket;
}
@@ -301,6 +311,17 @@ bool Bool::can_connect(const bNodeSocket &socket) const
return basic_types_can_connect(*this, socket);
}
+bNodeSocket &Bool::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const
+{
+ if (socket.type != SOCK_BOOLEAN) {
+ BLI_assert(socket.in_out == this->in_out);
+ return this->build(ntree, node);
+ }
+ this->set_common_flags(socket);
+ STRNCPY(socket.name, this->name.c_str());
+ return socket;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -346,6 +367,17 @@ bool Color::can_connect(const bNodeSocket &socket) const
return basic_types_can_connect(*this, socket);
}
+bNodeSocket &Color::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const
+{
+ if (socket.type != SOCK_RGBA) {
+ BLI_assert(socket.in_out == this->in_out);
+ return this->build(ntree, node);
+ }
+ this->set_common_flags(socket);
+ STRNCPY(socket.name, this->name.c_str());
+ return socket;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -382,6 +414,17 @@ bool String::can_connect(const bNodeSocket &socket) const
return sockets_can_connect(*this, socket) && socket.type == SOCK_STRING;
}
+bNodeSocket &String::update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const
+{
+ if (socket.type != SOCK_STRING) {
+ BLI_assert(socket.in_out == this->in_out);
+ return this->build(ntree, node);
+ }
+ this->set_common_flags(socket);
+ STRNCPY(socket.name, this->name.c_str());
+ return socket;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
More information about the Bf-blender-cvs
mailing list