Cleanup: Rename flag for node socket link status

"Is linked" is much clearer than "in use"
This commit is contained in:
Hans Goudey 2022-12-29 10:28:29 -05:00
parent 887105c4c9
commit 47b9ed2409
9 changed files with 20 additions and 20 deletions

View File

@ -523,10 +523,10 @@ class NodeTreeMainUpdater {
{
tree.ensure_topology_cache();
for (bNodeSocket *socket : tree.all_sockets()) {
socket->flag &= ~SOCK_IN_USE;
socket->flag &= ~SOCK_IS_LINKED;
for (const bNodeLink *link : socket->directly_linked_links()) {
if (!link->is_muted()) {
socket->flag |= SOCK_IN_USE;
socket->flag |= SOCK_IS_LINKED;
break;
}
}

View File

@ -225,22 +225,22 @@ static void do_versions_nodetree_socket_use_flags_2_62(bNodeTree *ntree)
for (node = ntree->nodes.first; node; node = node->next) {
for (sock = node->inputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_IN_USE;
sock->flag &= ~SOCK_IS_LINKED;
}
for (sock = node->outputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_IN_USE;
sock->flag &= ~SOCK_IS_LINKED;
}
}
for (sock = ntree->inputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_IN_USE;
sock->flag &= ~SOCK_IS_LINKED;
}
for (sock = ntree->outputs.first; sock; sock = sock->next) {
sock->flag &= ~SOCK_IN_USE;
sock->flag &= ~SOCK_IS_LINKED;
}
for (link = ntree->links.first; link; link = link->next) {
link->fromsock->flag |= SOCK_IN_USE;
link->tosock->flag |= SOCK_IN_USE;
link->fromsock->flag |= SOCK_IS_LINKED;
link->tosock->flag |= SOCK_IS_LINKED;
}
}

View File

@ -219,15 +219,15 @@ void version_socket_update_is_used(bNodeTree *ntree)
{
for (bNode *node : ntree->all_nodes()) {
LISTBASE_FOREACH (bNodeSocket *, socket, &node->inputs) {
socket->flag &= ~SOCK_IN_USE;
socket->flag &= ~SOCK_IS_LINKED;
}
LISTBASE_FOREACH (bNodeSocket *, socket, &node->outputs) {
socket->flag &= ~SOCK_IN_USE;
socket->flag &= ~SOCK_IS_LINKED;
}
}
LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) {
link->fromsock->flag |= SOCK_IN_USE;
link->tosock->flag |= SOCK_IN_USE;
link->fromsock->flag |= SOCK_IS_LINKED;
link->tosock->flag |= SOCK_IS_LINKED;
}
}

View File

@ -88,7 +88,7 @@ struct bNodeSocket *version_node_add_socket_if_not_exist(struct bNodeTree *ntree
const char *name);
/**
* The versioning code generally expects `SOCK_IN_USE` to be set correctly. This function updates
* The versioning code generally expects `SOCK_IS_LINKED` to be set correctly. This function updates
* the flag on all sockets after changes to the node tree.
*/
void version_socket_update_is_used(bNodeTree *ntree);

View File

@ -40,7 +40,7 @@
static bool socket_is_used(bNodeSocket *sock)
{
return sock->flag & SOCK_IN_USE;
return sock->flag & SOCK_IS_LINKED;
}
static float *cycles_node_socket_float_value(bNodeSocket *socket)
@ -371,7 +371,7 @@ static void light_emission_node_to_energy(Light *light, float *energy, float col
bNodeSocket *strength_socket = nodeFindSocket(emission_node, SOCK_IN, "Strength");
bNodeSocket *color_socket = nodeFindSocket(emission_node, SOCK_IN, "Color");
if ((strength_socket->flag & SOCK_IN_USE) || (color_socket->flag & SOCK_IN_USE)) {
if ((strength_socket->flag & SOCK_IS_LINKED) || (color_socket->flag & SOCK_IS_LINKED)) {
return;
}

View File

@ -1293,7 +1293,7 @@ static void std_node_socket_draw(
return;
}
if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_IN_USE) || (sock->flag & SOCK_HIDE_VALUE)) {
if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_IS_LINKED) || (sock->flag & SOCK_HIDE_VALUE)) {
node_socket_button_label(C, layout, ptr, node_ptr, text);
return;
}

View File

@ -176,7 +176,7 @@ static bool socket_is_available(bNodeTree * /*ntree*/, bNodeSocket *sock, const
return false;
}
if (!allow_used && (sock->flag & SOCK_IN_USE)) {
if (!allow_used && (sock->flag & SOCK_IS_LINKED)) {
/* Multi input sockets are available (even if used). */
if (!(sock->flag & SOCK_MULTI_INPUT)) {
return false;

View File

@ -256,7 +256,7 @@ typedef enum eNodeSocketFlag {
/** Hidden is user defined, to hide unused sockets. */
SOCK_HIDDEN = (1 << 1),
/** For quick check if socket is linked. */
SOCK_IN_USE = (1 << 2),
SOCK_IS_LINKED = (1 << 2),
/** Unavailable is for dynamic sockets. */
SOCK_UNAVAIL = (1 << 3),
// /** DEPRECATED dynamic socket (can be modified by user) */

View File

@ -2892,7 +2892,7 @@ static void rna_NodeSocket_hide_set(PointerRNA *ptr, bool value)
bNodeSocket *sock = (bNodeSocket *)ptr->data;
/* don't hide linked sockets */
if (sock->flag & SOCK_IN_USE) {
if (sock->flag & SOCK_IS_LINKED) {
return;
}
@ -11057,7 +11057,7 @@ static void rna_def_node_socket(BlenderRNA *brna)
RNA_def_property_update(prop, NC_NODE | NA_EDITED, NULL);
prop = RNA_def_property(srna, "is_linked", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_IN_USE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SOCK_IS_LINKED);
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Linked", "True if the socket is connected");