Cleanup: Replace manually flag checking by method in node.cc #107055

Merged
Hans Goudey merged 4 commits from mod_moder/blender:trying_to_replace_flag_chaking_be_methods into main 2023-04-18 00:29:22 +02:00
1 changed files with 8 additions and 9 deletions

View File

@ -1515,7 +1515,7 @@ bNodeSocket *node_find_enabled_socket(bNode &node,
{
ListBase *sockets = (in_out == SOCK_IN) ? &node.inputs : &node.outputs;
LISTBASE_FOREACH (bNodeSocket *, socket, sockets) {
if (!(socket->flag & SOCK_UNAVAIL) && socket->name == name) {
if (socket->is_available() && socket->name == name) {

I'm sure it doesn't make an observable difference, but I'd keep the checks ordered as they are, since checking the flag is likely cheaper than checking whether the name matches.

I'm sure it doesn't make an observable difference, but I'd keep the checks ordered as they are, since checking the flag is likely cheaper than checking whether the name matches.

I don't know how it happened. This is exactly what I was thinking and why did I change their order XD
have to go to bed..

I don't know how it happened. This is exactly what I was thinking and why did I change their order XD have to go to bed..
return socket;
}
}
@ -2582,7 +2582,7 @@ bNodeLink *nodeAddLink(
BKE_ntree_update_tag_link_added(ntree, link);
}
if (link != nullptr && link->tosock->flag & SOCK_MULTI_INPUT) {
if (link != nullptr && link->tosock->is_multi_input()) {
link->multi_input_socket_index = node_count_links(ntree, link->tosock) - 1;
}
@ -2608,7 +2608,7 @@ void nodeRemLink(bNodeTree *ntree, bNodeLink *link)
void nodeLinkSetMute(bNodeTree *ntree, bNodeLink *link, const bool muted)
{
const bool was_muted = link->flag & NODE_LINK_MUTED;
const bool was_muted = link->is_muted();
SET_FLAG_FROM_TEST(link->flag, muted, NODE_LINK_MUTED);
if (muted != was_muted) {
BKE_ntree_update_tag_link_mute(ntree, link);
@ -2670,7 +2670,7 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node)
bNodeLink *fromlink = internal_link ? internal_link->fromsock->link : nullptr;
if (fromlink == nullptr) {
if (link->tosock->flag & SOCK_MULTI_INPUT) {
if (link->tosock->is_multi_input()) {
adjust_multi_input_indices_after_removed_link(
ntree, link->tosock, link->multi_input_socket_index);
}
@ -2678,7 +2678,7 @@ void nodeInternalRelink(bNodeTree *ntree, bNode *node)
continue;
}
if (link->tosock->flag & SOCK_MULTI_INPUT) {
if (link->tosock->is_multi_input()) {
/* remove the link that would be the same as the relinked one */
LISTBASE_FOREACH_MUTABLE (bNodeLink *, link_to_compare, &ntree->links) {
if (link_to_compare->fromsock == fromlink->fromsock &&
@ -3086,7 +3086,7 @@ void nodeUnlinkNode(bNodeTree *ntree, bNode *node)
if (lb) {
/* Only bother adjusting if the socket is not on the node we're deleting. */
if (link->tonode != node && link->tosock->flag & SOCK_MULTI_INPUT) {
if (link->tonode != node && link->tosock->is_multi_input()) {
adjust_multi_input_indices_after_removed_link(
ntree, link->tosock, link->multi_input_socket_index);
}
@ -3733,8 +3733,7 @@ void nodeSetActive(bNodeTree *ntree, bNode *node)
void nodeSetSocketAvailability(bNodeTree *ntree, bNodeSocket *sock, const bool is_available)
{
const bool was_available = (sock->flag & SOCK_UNAVAIL) == 0;
if (is_available == was_available) {
if (is_available == sock->is_available()) {
return;
}
if (is_available) {
@ -3748,7 +3747,7 @@ void nodeSetSocketAvailability(bNodeTree *ntree, bNodeSocket *sock, const bool i
int nodeSocketLinkLimit(const bNodeSocket *sock)
{
if (sock->flag & SOCK_MULTI_INPUT) {
if (sock->is_multi_input()) {
return 4095;
}
if (sock->typeinfo == nullptr) {