Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-04-22 06:31:31 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-04-22 12:48:17 +0300
commitb102472551c351d8be8ebf96e3e44a5454f02d0a (patch)
tree1ccd80b94db736cd45f2c038c22e1c7b43642ded /source/blender/nodes/intern
parent735515a3f9e4c41738bf714d682b13db64adb638 (diff)
Cleanup: style, use braces for nodes
Diffstat (limited to 'source/blender/nodes/intern')
-rw-r--r--source/blender/nodes/intern/node_common.c90
-rw-r--r--source/blender/nodes/intern/node_exec.c63
-rw-r--r--source/blender/nodes/intern/node_socket.c24
-rw-r--r--source/blender/nodes/intern/node_util.c36
4 files changed, 142 insertions, 71 deletions
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index d9ea6425b01..ed4cdde67f0 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -52,18 +52,22 @@ enum {
bNodeSocket *node_group_find_input_socket(bNode *groupnode, const char *identifier)
{
bNodeSocket *sock;
- for (sock = groupnode->inputs.first; sock; sock = sock->next)
- if (STREQ(sock->identifier, identifier))
+ for (sock = groupnode->inputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->identifier, identifier)) {
return sock;
+ }
+ }
return NULL;
}
bNodeSocket *node_group_find_output_socket(bNode *groupnode, const char *identifier)
{
bNodeSocket *sock;
- for (sock = groupnode->outputs.first; sock; sock = sock->next)
- if (STREQ(sock->identifier, identifier))
+ for (sock = groupnode->outputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->identifier, identifier)) {
return sock;
+ }
+ }
return NULL;
}
@@ -77,13 +81,16 @@ bool node_group_poll_instance(bNode *node, bNodeTree *nodetree)
{
if (node->typeinfo->poll(node->typeinfo, nodetree)) {
bNodeTree *grouptree = (bNodeTree *)node->id;
- if (grouptree)
+ if (grouptree) {
return nodeGroupPoll(nodetree, grouptree);
- else
+ }
+ else {
return true; /* without a linked node tree, group node is always ok */
+ }
}
- else
+ else {
return false;
+ }
}
int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
@@ -94,11 +101,13 @@ int nodeGroupPoll(bNodeTree *nodetree, bNodeTree *grouptree)
/* unspecified node group, generally allowed
* (if anything, should be avoided on operator level)
*/
- if (grouptree == NULL)
+ if (grouptree == NULL) {
return 1;
+ }
- if (nodetree == grouptree)
+ if (nodetree == grouptree) {
return 0;
+ }
for (node = grouptree->nodes.first; node; node = node->next) {
if (node->typeinfo->poll_instance && !node->typeinfo->poll_instance(node, nodetree)) {
@@ -116,20 +125,23 @@ static bNodeSocket *group_verify_socket(
bNodeSocket *sock;
for (sock = verify_lb->first; sock; sock = sock->next) {
- if (STREQ(sock->identifier, iosock->identifier))
+ if (STREQ(sock->identifier, iosock->identifier)) {
break;
+ }
}
if (sock) {
strcpy(sock->name, iosock->name);
- if (iosock->typeinfo->interface_verify_socket)
+ if (iosock->typeinfo->interface_verify_socket) {
iosock->typeinfo->interface_verify_socket(ntree, iosock, gnode, sock, "interface");
+ }
}
else {
sock = nodeAddSocket(ntree, gnode, in_out, iosock->idname, iosock->identifier, iosock->name);
- if (iosock->typeinfo->interface_init_socket)
+ if (iosock->typeinfo->interface_init_socket) {
iosock->typeinfo->interface_init_socket(ntree, iosock, gnode, sock, "interface");
+ }
}
/* remove from list temporarily, to distinguish from orphaned sockets */
@@ -216,8 +228,9 @@ static void node_reroute_update_internal_links(bNodeTree *ntree, bNode *node)
bNodeLink *link;
/* Security check! */
- if (!ntree)
+ if (!ntree) {
return;
+ }
link = MEM_callocN(sizeof(bNodeLink), "internal node link");
link->fromnode = node;
@@ -270,18 +283,22 @@ static void node_reroute_inherit_type_recursive(bNodeTree *ntree, bNode *node, i
for (link = ntree->links.first; link; link = link->next) {
bNode *fromnode = link->fromnode;
bNode *tonode = link->tonode;
- if (!tonode || !fromnode)
+ if (!tonode || !fromnode) {
continue;
- if (nodeLinkIsHidden(link))
+ }
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
if (flag & REFINE_FORWARD) {
- if (tonode == node && fromnode->type == NODE_REROUTE && !fromnode->done)
+ if (tonode == node && fromnode->type == NODE_REROUTE && !fromnode->done) {
node_reroute_inherit_type_recursive(ntree, fromnode, REFINE_FORWARD);
+ }
}
if (flag & REFINE_BACKWARD) {
- if (fromnode == node && tonode->type == NODE_REROUTE && !tonode->done)
+ if (fromnode == node && tonode->type == NODE_REROUTE && !tonode->done) {
node_reroute_inherit_type_recursive(ntree, tonode, REFINE_BACKWARD);
+ }
}
}
@@ -327,12 +344,15 @@ void ntree_update_reroute_nodes(bNodeTree *ntree)
bNode *node;
/* clear tags */
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
node->done = 0;
+ }
- for (node = ntree->nodes.first; node; node = node->next)
- if (node->type == NODE_REROUTE && !node->done)
+ for (node = ntree->nodes.first; node; node = node->next) {
+ if (node->type == NODE_REROUTE && !node->done) {
node_reroute_inherit_type_recursive(ntree, node, REFINE_FORWARD | REFINE_BACKWARD);
+ }
+ }
}
static bool node_is_connected_to_output_recursive(bNodeTree *ntree, bNode *node)
@@ -340,19 +360,22 @@ static bool node_is_connected_to_output_recursive(bNodeTree *ntree, bNode *node)
bNodeLink *link;
/* avoid redundant checks, and infinite loops in case of cyclic node links */
- if (node->done)
+ if (node->done) {
return false;
+ }
node->done = 1;
/* main test, done before child loop so it catches output nodes themselves as well */
- if (node->typeinfo->nclass == NODE_CLASS_OUTPUT && node->flag & NODE_DO_OUTPUT)
+ if (node->typeinfo->nclass == NODE_CLASS_OUTPUT && node->flag & NODE_DO_OUTPUT) {
return true;
+ }
/* test all connected nodes, first positive find is sufficient to return true */
for (link = ntree->links.first; link; link = link->next) {
if (link->fromnode == node) {
- if (node_is_connected_to_output_recursive(ntree, link->tonode))
+ if (node_is_connected_to_output_recursive(ntree, link->tonode)) {
return true;
+ }
}
}
return false;
@@ -363,8 +386,9 @@ bool BKE_node_is_connected_to_output(bNodeTree *ntree, bNode *node)
bNode *tnode;
/* clear flags */
- for (tnode = ntree->nodes.first; tnode; tnode = tnode->next)
+ for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
tnode->done = 0;
+ }
return node_is_connected_to_output_recursive(ntree, node);
}
@@ -390,9 +414,11 @@ static void node_group_input_init(bNodeTree *ntree, bNode *node)
bNodeSocket *node_group_input_find_socket(bNode *node, const char *identifier)
{
bNodeSocket *sock;
- for (sock = node->outputs.first; sock; sock = sock->next)
- if (STREQ(sock->identifier, identifier))
+ for (sock = node->outputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->identifier, identifier)) {
return sock;
+ }
+ }
return NULL;
}
@@ -422,8 +448,9 @@ static void node_group_input_update(bNodeTree *ntree, bNode *node)
BLI_listbase_clear(&tmplinks);
for (link = ntree->links.first; link; link = linknext) {
linknext = link->next;
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
if (link->fromsock == extsock) {
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
@@ -487,9 +514,11 @@ static void node_group_output_init(bNodeTree *ntree, bNode *node)
bNodeSocket *node_group_output_find_socket(bNode *node, const char *identifier)
{
bNodeSocket *sock;
- for (sock = node->inputs.first; sock; sock = sock->next)
- if (STREQ(sock->identifier, identifier))
+ for (sock = node->inputs.first; sock; sock = sock->next) {
+ if (STREQ(sock->identifier, identifier)) {
return sock;
+ }
+ }
return NULL;
}
@@ -519,8 +548,9 @@ static void node_group_output_update(bNodeTree *ntree, bNode *node)
BLI_listbase_clear(&tmplinks);
for (link = ntree->links.first; link; link = linknext) {
linknext = link->next;
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
if (link->tosock == extsock) {
bNodeLink *tlink = MEM_callocN(sizeof(bNodeLink), "temporary link");
diff --git a/source/blender/nodes/intern/node_exec.c b/source/blender/nodes/intern/node_exec.c
index ed3dbf4515b..7fcba8cb472 100644
--- a/source/blender/nodes/intern/node_exec.c
+++ b/source/blender/nodes/intern/node_exec.c
@@ -44,8 +44,9 @@ int node_exec_socket_use_stack(bNodeSocket *sock)
/* for a given socket, find the actual stack entry */
bNodeStack *node_get_socket_stack(bNodeStack *stack, bNodeSocket *sock)
{
- if (stack && sock && sock->stack_index >= 0)
+ if (stack && sock && sock->stack_index >= 0) {
return stack + sock->stack_index;
+ }
return NULL;
}
@@ -74,10 +75,12 @@ static void node_init_input_index(bNodeSocket *sock, int *index)
sock->stack_index = sock->link->fromsock->stack_index;
}
else {
- if (node_exec_socket_use_stack(sock))
+ if (node_exec_socket_use_stack(sock)) {
sock->stack_index = (*index)++;
- else
+ }
+ else {
sock->stack_index = -1;
+ }
}
}
@@ -98,17 +101,21 @@ static void node_init_output_index(bNodeSocket *sock, int *index, ListBase *inte
}
/* if not internally connected, assign a new stack index anyway to avoid bad stack access */
if (!link) {
- if (node_exec_socket_use_stack(sock))
+ if (node_exec_socket_use_stack(sock)) {
sock->stack_index = (*index)++;
- else
+ }
+ else {
sock->stack_index = -1;
+ }
}
}
else {
- if (node_exec_socket_use_stack(sock))
+ if (node_exec_socket_use_stack(sock)) {
sock->stack_index = (*index)++;
- else
+ }
+ else {
sock->stack_index = -1;
+ }
}
}
@@ -119,12 +126,14 @@ static struct bNodeStack *setup_stack(bNodeStack *stack,
bNodeSocket *sock)
{
bNodeStack *ns = node_get_socket_stack(stack, sock);
- if (!ns)
+ if (!ns) {
return NULL;
+ }
/* don't mess with remote socket stacks, these are initialized by other nodes! */
- if (sock->link)
+ if (sock->link) {
return ns;
+ }
ns->sockettype = sock->type;
@@ -179,16 +188,19 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
node->stack_index = index;
/* init node socket stack indexes */
- for (sock = node->inputs.first; sock; sock = sock->next)
+ for (sock = node->inputs.first; sock; sock = sock->next) {
node_init_input_index(sock, &index);
+ }
if (node->flag & NODE_MUTED || node->type == NODE_REROUTE) {
- for (sock = node->outputs.first; sock; sock = sock->next)
+ for (sock = node->outputs.first; sock; sock = sock->next) {
node_init_output_index(sock, &index, &node->internal_links);
+ }
}
else {
- for (sock = node->outputs.first; sock; sock = sock->next)
+ for (sock = node->outputs.first; sock; sock = sock->next) {
node_init_output_index(sock, &index, NULL);
+ }
}
}
@@ -200,8 +212,9 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
exec->stack = MEM_callocN(exec->stacksize * sizeof(bNodeStack), "bNodeStack");
/* all non-const results are considered inputs */
- for (n = 0; n < exec->stacksize; ++n)
+ for (n = 0; n < exec->stacksize; ++n) {
exec->stack[n].hasinput = 1;
+ }
/* prepare all nodes for execution */
for (n = 0, nodeexec = exec->nodeexec; n < totnodes; ++n, ++nodeexec) {
@@ -211,12 +224,14 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
/* tag inputs */
for (sock = node->inputs.first; sock; sock = sock->next) {
/* disable the node if an input link is invalid */
- if (sock->link && !(sock->link->flag & NODE_LINK_VALID))
+ if (sock->link && !(sock->link->flag & NODE_LINK_VALID)) {
node->need_exec = 0;
+ }
ns = setup_stack(exec->stack, ntree, node, sock);
- if (ns)
+ if (ns) {
ns->hasoutput = 1;
+ }
}
/* tag all outputs */
@@ -228,12 +243,14 @@ bNodeTreeExec *ntree_exec_begin(bNodeExecContext *context,
nodeexec->data.preview = context->previews ?
BKE_node_instance_hash_lookup(context->previews, nodekey) :
NULL;
- if (node->typeinfo->initexecfunc)
+ if (node->typeinfo->initexecfunc) {
nodeexec->data.data = node->typeinfo->initexecfunc(context, node, nodekey);
+ }
}
- if (nodelist)
+ if (nodelist) {
MEM_freeN(nodelist);
+ }
return exec;
}
@@ -243,16 +260,19 @@ void ntree_exec_end(bNodeTreeExec *exec)
bNodeExec *nodeexec;
int n;
- if (exec->stack)
+ if (exec->stack) {
MEM_freeN(exec->stack);
+ }
for (n = 0, nodeexec = exec->nodeexec; n < exec->totnodes; ++n, ++nodeexec) {
- if (nodeexec->freeexecfunc)
+ if (nodeexec->freeexecfunc) {
nodeexec->freeexecfunc(nodeexec->data.data);
+ }
}
- if (exec->nodeexec)
+ if (exec->nodeexec) {
MEM_freeN(exec->nodeexec);
+ }
MEM_freeN(exec);
}
@@ -304,8 +324,9 @@ bool ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call
* If the mute func is not set, assume the node should never be muted,
* and hence execute it!
*/
- if (node->typeinfo->execfunc && !(node->flag & NODE_MUTED))
+ if (node->typeinfo->execfunc && !(node->flag & NODE_MUTED)) {
node->typeinfo->execfunc(callerdata, thread, node, &nodeexec->data, nsin, nsout);
+ }
}
}
diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c
index 9fe6e0bcecb..8aeada7bde0 100644
--- a/source/blender/nodes/intern/node_socket.c
+++ b/source/blender/nodes/intern/node_socket.c
@@ -100,8 +100,9 @@ static bNodeSocket *verify_socket_template(
bNodeSocket *sock;
for (sock = socklist->first; sock; sock = sock->next) {
- if (STREQLEN(sock->name, stemp->name, NODE_MAXSTR))
+ if (STREQLEN(sock->name, stemp->name, NODE_MAXSTR)) {
break;
+ }
}
if (sock) {
if (sock->type != stemp->type) {
@@ -182,10 +183,12 @@ void node_verify_socket_templates(bNodeTree *ntree, bNode *node)
* render layer node since it still has fixed sockets too.
*/
if (ntype) {
- if (ntype->inputs && ntype->inputs[0].type >= 0)
+ if (ntype->inputs && ntype->inputs[0].type >= 0) {
verify_socket_template_list(ntree, node, SOCK_IN, &node->inputs, ntype->inputs);
- if (ntype->outputs && ntype->outputs[0].type >= 0 && node->type != CMP_NODE_R_LAYERS)
+ }
+ if (ntype->outputs && ntype->outputs[0].type >= 0 && node->type != CMP_NODE_R_LAYERS) {
verify_socket_template_list(ntree, node, SOCK_OUT, &node->outputs, ntype->outputs);
+ }
}
}
@@ -194,8 +197,9 @@ void node_socket_init_default_value(bNodeSocket *sock)
int type = sock->typeinfo->type;
int subtype = sock->typeinfo->subtype;
- if (sock->default_value)
+ if (sock->default_value) {
return; /* already initialized */
+ }
switch (type) {
case SOCK_FLOAT: {
@@ -264,12 +268,14 @@ void node_socket_init_default_value(bNodeSocket *sock)
void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from)
{
/* sanity check */
- if (to->type != from->type)
+ if (to->type != from->type) {
return;
+ }
/* make sure both exist */
- if (!from->default_value)
+ if (!from->default_value) {
return;
+ }
node_socket_init_default_value(to);
switch (from->typeinfo->type) {
@@ -339,12 +345,14 @@ static void standard_node_socket_interface_verify_socket(bNodeTree *UNUSED(ntree
const char *UNUSED(data_path))
{
/* sanity check */
- if (sock->type != stemp->typeinfo->type)
+ if (sock->type != stemp->typeinfo->type) {
return;
+ }
/* make sure both exist */
- if (!stemp->default_value)
+ if (!stemp->default_value) {
return;
+ }
node_socket_init_default_value(sock);
switch (stemp->typeinfo->type) {
diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c
index a4a39caf8df..4141ccccafa 100644
--- a/source/blender/nodes/intern/node_util.c
+++ b/source/blender/nodes/intern/node_util.c
@@ -131,8 +131,9 @@ static bool node_link_socket_match(bNodeSocket *a, bNodeSocket *b)
/* end of common prefix? */
if (*ca != *cb) {
/* prefix delimited by non-alphabetic char */
- if (isalpha(*ca) || isalpha(*cb))
+ if (isalpha(*ca) || isalpha(*cb)) {
return false;
+ }
break;
}
++prefix_len;
@@ -145,10 +146,12 @@ static int node_count_links(bNodeTree *ntree, bNodeSocket *sock)
bNodeLink *link;
int count = 0;
for (link = ntree->links.first; link; link = link->next) {
- if (link->fromsock == sock)
+ if (link->fromsock == sock) {
++count;
- if (link->tosock == sock)
+ }
+ if (link->tosock == sock) {
++count;
+ }
}
return count;
}
@@ -166,8 +169,9 @@ static bNodeSocket *node_find_linkable_socket(bNodeTree *ntree, bNode *node, bNo
if (!nodeSocketIsHidden(sock) && node_link_socket_match(sock, cur)) {
int link_count = node_count_links(ntree, sock);
/* take +1 into account since we would add a new link */
- if (link_count + 1 <= sock->limit)
+ if (link_count + 1 <= sock->limit) {
return sock; /* found a valid free socket we can swap to */
+ }
}
sock = sock->next ? sock->next : first; /* wrap around the list end */
@@ -181,15 +185,17 @@ void node_insert_link_default(bNodeTree *ntree, bNode *node, bNodeLink *link)
bNodeLink *tlink, *tlink_next;
/* inputs can have one link only, outputs can have unlimited links */
- if (node != link->tonode)
+ if (node != link->tonode) {
return;
+ }
for (tlink = ntree->links.first; tlink; tlink = tlink_next) {
bNodeSocket *new_sock;
tlink_next = tlink->next;
- if (sock != tlink->tosock)
+ if (sock != tlink->tosock) {
continue;
+ }
new_sock = node_find_linkable_socket(ntree, node, sock);
if (new_sock && new_sock != sock) {
@@ -346,22 +352,27 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
bNodeSocket *output, *input;
/* sanity check */
- if (!ntree)
+ if (!ntree) {
return;
+ }
/* use link pointer as a tag for handled sockets (for outputs is unused anyway) */
- for (output = node->outputs.first; output; output = output->next)
+ for (output = node->outputs.first; output; output = output->next) {
output->link = NULL;
+ }
for (link = ntree->links.first; link; link = link->next) {
- if (nodeLinkIsHidden(link))
+ if (nodeLinkIsHidden(link)) {
continue;
+ }
output = link->fromsock;
- if (link->fromnode != node || output->link)
+ if (link->fromnode != node || output->link) {
continue;
- if (nodeSocketIsHidden(output) || output->flag & SOCK_NO_INTERNAL_LINK)
+ }
+ if (nodeSocketIsHidden(output) || output->flag & SOCK_NO_INTERNAL_LINK) {
continue;
+ }
output->link = link; /* not really used, just for tagging handled sockets */
/* look for suitable input */
@@ -380,8 +391,9 @@ void node_update_internal_links_default(bNodeTree *ntree, bNode *node)
}
/* clean up */
- for (output = node->outputs.first; output; output = output->next)
+ for (output = node->outputs.first; output; output = output->next) {
output->link = NULL;
+ }
}
/**** Default value RNA access ****/