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>2012-03-24 10:38:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-03-24 10:38:07 +0400
commitab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch)
tree81af4c18519181490074508dbe9a8d515eab634f /source/blender/editors/space_node/node_templates.c
parent5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff)
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/space_node/node_templates.c')
-rw-r--r--source/blender/editors/space_node/node_templates.c162
1 files changed, 81 insertions, 81 deletions
diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c
index 298867c18af..3d841b05632 100644
--- a/source/blender/editors/space_node/node_templates.c
+++ b/source/blender/editors/space_node/node_templates.c
@@ -67,13 +67,13 @@ static void node_tag_recursive(bNode *node)
{
bNodeSocket *input;
- if(!node || (node->flag & NODE_TEST))
+ if (!node || (node->flag & NODE_TEST))
return; /* in case of cycles */
node->flag |= NODE_TEST;
- for(input=node->inputs.first; input; input=input->next)
- if(input->link)
+ for (input=node->inputs.first; input; input=input->next)
+ if (input->link)
node_tag_recursive(input->link->fromnode);
}
@@ -81,13 +81,13 @@ static void node_clear_recursive(bNode *node)
{
bNodeSocket *input;
- if(!node || !(node->flag & NODE_TEST))
+ if (!node || !(node->flag & NODE_TEST))
return; /* in case of cycles */
node->flag &= ~NODE_TEST;
- for(input=node->inputs.first; input; input=input->next)
- if(input->link)
+ for (input=node->inputs.first; input; input=input->next)
+ if (input->link)
node_clear_recursive(input->link->fromnode);
}
@@ -96,28 +96,28 @@ static void node_remove_linked(bNodeTree *ntree, bNode *rem_node)
bNode *node, *next;
bNodeSocket *sock;
- if(!rem_node)
+ if (!rem_node)
return;
/* tag linked nodes to be removed */
- for(node=ntree->nodes.first; node; node=node->next)
+ for (node=ntree->nodes.first; node; node=node->next)
node->flag &= ~NODE_TEST;
node_tag_recursive(rem_node);
/* clear tags on nodes that are still used by other nodes */
- for(node=ntree->nodes.first; node; node=node->next)
- if(!(node->flag & NODE_TEST))
- for(sock=node->inputs.first; sock; sock=sock->next)
- if(sock->link && sock->link->fromnode != rem_node)
+ for (node=ntree->nodes.first; node; node=node->next)
+ if (!(node->flag & NODE_TEST))
+ for (sock=node->inputs.first; sock; sock=sock->next)
+ if (sock->link && sock->link->fromnode != rem_node)
node_clear_recursive(sock->link->fromnode);
/* remove nodes */
- for(node=ntree->nodes.first; node; node=next) {
+ for (node=ntree->nodes.first; node; node=next) {
next = node->next;
- if(node->flag & NODE_TEST) {
- if(node->id)
+ if (node->flag & NODE_TEST) {
+ if (node->id)
node->id->us--;
nodeFreeNode(ntree, node);
}
@@ -127,7 +127,7 @@ static void node_remove_linked(bNodeTree *ntree, bNode *rem_node)
/* disconnect socket from the node it is connected to */
static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to)
{
- if(!sock_to->link)
+ if (!sock_to->link)
return;
nodeRemLink(ntree, sock_to->link);
@@ -141,7 +141,7 @@ static void node_socket_disconnect(Main *bmain, bNodeTree *ntree, bNode *node_to
/* remove all nodes connected to this socket, if they aren't connected to other nodes */
static void node_socket_remove(Main *bmain, bNodeTree *ntree, bNode *node_to, bNodeSocket *sock_to)
{
- if(!sock_to->link)
+ if (!sock_to->link)
return;
node_remove_linked(ntree, sock_to->link->fromnode);
@@ -160,31 +160,31 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
bNode *node_prev = NULL;
/* unlink existing node */
- if(sock_to->link) {
+ if (sock_to->link) {
node_prev = sock_to->link->fromnode;
nodeRemLink(ntree, sock_to->link);
}
/* find existing node that we can use */
- for(node_from=ntree->nodes.first; node_from; node_from=node_from->next)
- if(node_from->type == ntemp->type)
+ for (node_from=ntree->nodes.first; node_from; node_from=node_from->next)
+ if (node_from->type == ntemp->type)
break;
- if(node_from)
- if(!(node_from->inputs.first == NULL && !(node_from->typeinfo->flag & NODE_OPTIONS)))
+ if (node_from)
+ if (!(node_from->inputs.first == NULL && !(node_from->typeinfo->flag & NODE_OPTIONS)))
node_from = NULL;
- if(node_prev && node_prev->type == ntemp->type &&
+ if (node_prev && node_prev->type == ntemp->type &&
(ntemp->type != NODE_GROUP || node_prev->id == &ntemp->ngroup->id)) {
/* keep the previous node if it's the same type */
node_from = node_prev;
}
- else if(!node_from) {
+ else if (!node_from) {
node_from= nodeAddNode(ntree, ntemp);
node_from->locx = node_to->locx - (node_from->typeinfo->width + 50);
node_from->locy = node_to->locy;
- if(node_from->id)
+ if (node_from->id)
id_us_plus(node_from->id);
}
@@ -195,18 +195,18 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
nodeAddLink(ntree, node_from, sock_from, node_to, sock_to);
/* copy input sockets from previous node */
- if(node_prev && node_from != node_prev) {
+ if (node_prev && node_from != node_prev) {
bNodeSocket *sock_prev, *sock_from;
- for(sock_prev=node_prev->inputs.first; sock_prev; sock_prev=sock_prev->next) {
- for(sock_from=node_from->inputs.first; sock_from; sock_from=sock_from->next) {
+ for (sock_prev=node_prev->inputs.first; sock_prev; sock_prev=sock_prev->next) {
+ for (sock_from=node_from->inputs.first; sock_from; sock_from=sock_from->next) {
if (nodeCountSocketLinks(ntree, sock_from) >= sock_from->limit)
continue;
- if(strcmp(sock_prev->name, sock_from->name) == 0 && sock_prev->type == sock_from->type) {
+ if (strcmp(sock_prev->name, sock_from->name) == 0 && sock_prev->type == sock_from->type) {
bNodeLink *link = sock_prev->link;
- if(link && link->fromnode) {
+ if (link && link->fromnode) {
nodeAddLink(ntree, link->fromnode, link->fromsock, node_from, sock_from);
nodeRemLink(ntree, link);
}
@@ -219,7 +219,7 @@ static void node_socket_add_replace(Main *bmain, bNodeTree *ntree, bNode *node_t
}
/* also preserve mapping for texture nodes */
- if(node_from->typeinfo->nclass == NODE_CLASS_TEXTURE &&
+ if (node_from->typeinfo->nclass == NODE_CLASS_TEXTURE &&
node_prev->typeinfo->nclass == NODE_CLASS_TEXTURE)
memcpy(node_from->storage, node_prev->storage, sizeof(NodeTexBase));
@@ -267,9 +267,9 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p)
ntemp.type = arg->type;
ntemp.ngroup = arg->ngroup;
- if(event == UI_NODE_LINK_DISCONNECT)
+ if (event == UI_NODE_LINK_DISCONNECT)
node_socket_disconnect(bmain, ntree, node_to, sock_to);
- else if(event == UI_NODE_LINK_REMOVE)
+ else if (event == UI_NODE_LINK_REMOVE)
node_socket_remove(bmain, ntree, node_to, sock_to);
else
node_socket_add_replace(bmain, ntree, node_to, sock_to, &ntemp, arg->output);
@@ -279,11 +279,11 @@ static void ui_node_link(bContext *C, void *arg_p, void *event_p)
static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR])
{
- if(sock->link && sock->link->fromnode) {
+ if (sock->link && sock->link->fromnode) {
bNode *node = sock->link->fromnode;
char node_name[UI_MAX_NAME_STR];
- if(node->type == NODE_GROUP) {
+ if (node->type == NODE_GROUP) {
if (node->id)
BLI_strncpy(node_name, node->id->name+2, UI_MAX_NAME_STR);
else
@@ -292,14 +292,14 @@ static void ui_node_sock_name(bNodeSocket *sock, char name[UI_MAX_NAME_STR])
else
BLI_strncpy(node_name, node->typeinfo->name, UI_MAX_NAME_STR);
- if(node->inputs.first == NULL &&
+ if (node->inputs.first == NULL &&
node->outputs.first != node->outputs.last &&
!(node->typeinfo->flag & NODE_OPTIONS))
BLI_snprintf(name, UI_MAX_NAME_STR, "%s | %s", node_name, sock->link->fromsock->name);
else
BLI_strncpy(name, node_name, UI_MAX_NAME_STR);
}
- else if(sock->type == SOCK_SHADER)
+ else if (sock->type == SOCK_SHADER)
BLI_strncpy(name, "None", UI_MAX_NAME_STR);
else
BLI_strncpy(name, "Default", UI_MAX_NAME_STR);
@@ -325,31 +325,31 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
int first = 1;
int compatibility= 0;
- if(ntree->type == NTREE_SHADER) {
- if(scene_use_new_shading_nodes(arg->scene))
+ if (ntree->type == NTREE_SHADER) {
+ if (scene_use_new_shading_nodes(arg->scene))
compatibility= NODE_NEW_SHADING;
else
compatibility= NODE_OLD_SHADING;
}
- if(nclass == NODE_CLASS_GROUP) {
- for(ngroup=bmain->nodetree.first; ngroup; ngroup=ngroup->id.next) {
+ if (nclass == NODE_CLASS_GROUP) {
+ for (ngroup=bmain->nodetree.first; ngroup; ngroup=ngroup->id.next) {
bNodeSocket *gsock;
char name[UI_MAX_NAME_STR];
int i, j, num = 0;
- if(ngroup->type != ntree->type)
+ if (ngroup->type != ntree->type)
continue;
- for(gsock=ngroup->inputs.first; gsock; gsock=gsock->next)
- if(ui_compatible_sockets(gsock->type, sock->type))
+ for (gsock=ngroup->inputs.first; gsock; gsock=gsock->next)
+ if (ui_compatible_sockets(gsock->type, sock->type))
num++;
- for(i=0, j=0, gsock=ngroup->outputs.first; gsock; gsock=gsock->next, i++) {
- if(!ui_compatible_sockets(gsock->type, sock->type))
+ for (i=0, j=0, gsock=ngroup->outputs.first; gsock; gsock=gsock->next, i++) {
+ if (!ui_compatible_sockets(gsock->type, sock->type))
continue;
- if(first) {
+ if (first) {
column= uiLayoutColumn(layout, 0);
uiBlockSetCurLayout(block, column);
@@ -360,8 +360,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
first = 0;
}
- if(num > 1) {
- if(j == 0) {
+ if (num > 1) {
+ if (j == 0) {
uiItemL(column, ngroup->id.name+2, ICON_NODE);
but= block->buttons.last;
but->flag= UI_TEXT_LEFT;
@@ -387,26 +387,26 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
else {
bNodeTreeType *ttype= ntreeGetType(ntree->type);
- for(ntype=ttype->node_types.first; ntype; ntype=ntype->next) {
+ for (ntype=ttype->node_types.first; ntype; ntype=ntype->next) {
bNodeSocketTemplate *stemp;
char name[UI_MAX_NAME_STR];
int i, j, num = 0;
- if(compatibility && !(ntype->compatibility & compatibility))
+ if (compatibility && !(ntype->compatibility & compatibility))
continue;
- if(ntype->nclass != nclass)
+ if (ntype->nclass != nclass)
continue;
- for(i=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++)
- if(ui_compatible_sockets(stemp->type, sock->type))
+ for (i=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++)
+ if (ui_compatible_sockets(stemp->type, sock->type))
num++;
- for(i=0, j=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) {
- if(!ui_compatible_sockets(stemp->type, sock->type))
+ for (i=0, j=0, stemp=ntype->outputs; stemp && stemp->type != -1; stemp++, i++) {
+ if (!ui_compatible_sockets(stemp->type, sock->type))
continue;
- if(first) {
+ if (first) {
column= uiLayoutColumn(layout, 0);
uiBlockSetCurLayout(block, column);
@@ -417,8 +417,8 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname)
first = 0;
}
- if(num > 1) {
- if(j == 0) {
+ if (num > 1) {
+ if (j == 0) {
uiItemL(column, ntype->name, ICON_NODE);
but= block->buttons.last;
but->flag= UI_TEXT_LEFT;
@@ -446,7 +446,7 @@ static void node_menu_column_foreach_cb(void *calldata, int nclass, const char *
{
NodeLinkArg *arg = (NodeLinkArg*)calldata;
- if(!ELEM(nclass, NODE_CLASS_GROUP, NODE_CLASS_LAYOUT))
+ if (!ELEM(nclass, NODE_CLASS_GROUP, NODE_CLASS_LAYOUT))
ui_node_menu_column(arg, nclass, name);
}
@@ -468,13 +468,13 @@ static void ui_template_node_link_menu(bContext *C, uiLayout *layout, void *but_
arg->scene= scene;
arg->layout= split;
- if(ntreetype && ntreetype->foreach_nodeclass)
+ if (ntreetype && ntreetype->foreach_nodeclass)
ntreetype->foreach_nodeclass(scene, arg, node_menu_column_foreach_cb);
column= uiLayoutColumn(split, 0);
uiBlockSetCurLayout(block, column);
- if(sock->link) {
+ if (sock->link) {
uiItemL(column, "Link", ICON_NONE);
but= block->buttons.last;
but->flag= UI_TEXT_LEFT;
@@ -506,7 +506,7 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo
uiBlockSetCurLayout(block, layout);
- if(sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) {
+ if (sock->link || sock->type == SOCK_SHADER || (sock->flag & SOCK_HIDE_VALUE)) {
char name[UI_MAX_NAME_STR];
ui_node_sock_name(sock, name);
but = uiDefMenuBut(block, ui_template_node_link_menu, NULL, name, 0, 0, UI_UNIT_X*4, UI_UNIT_Y, "");
@@ -519,8 +519,8 @@ void uiTemplateNodeLink(uiLayout *layout, bNodeTree *ntree, bNode *node, bNodeSo
but->poin= (char*)but;
but->func_argN = arg;
- if(sock->link && sock->link->fromnode)
- if(sock->link->fromnode->flag & NODE_ACTIVE_TEXTURE)
+ if (sock->link && sock->link->fromnode)
+ if (sock->link->fromnode->flag & NODE_ACTIVE_TEXTURE)
but->flag |= UI_BUT_NODE_ACTIVE;
}
@@ -537,8 +537,8 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
- if(node->typeinfo->uifunc) {
- if(node->type != NODE_GROUP) {
+ if (node->typeinfo->uifunc) {
+ if (node->type != NODE_GROUP) {
split = uiLayoutSplit(layout, 0.35f, 0);
col = uiLayoutColumn(split, 0);
col = uiLayoutColumn(split, 0);
@@ -547,7 +547,7 @@ static void ui_node_draw_node(uiLayout *layout, bContext *C, bNodeTree *ntree, b
}
}
- for(input=node->inputs.first; input; input=input->next)
+ for (input=node->inputs.first; input; input=input->next)
ui_node_draw_input(layout, C, ntree, node, input, depth+1);
}
@@ -562,7 +562,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
int indent = (depth > 1)? 2*(depth - 1): 0;
int dependency_loop;
- if(input->flag & SOCK_UNAVAIL)
+ if (input->flag & SOCK_UNAVAIL)
return;
/* to avoid eternal loops on cyclic dependencies */
@@ -570,7 +570,7 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
lnode = (input->link)? input->link->fromnode: NULL;
dependency_loop = (lnode && (lnode->flag & NODE_TEST));
- if(dependency_loop)
+ if (dependency_loop)
lnode = NULL;
/* socket RNA pointer */
@@ -586,10 +586,10 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
row = uiLayoutRow(split, 1);
- if(depth > 0) {
+ if (depth > 0) {
uiBlockSetEmboss(block, UI_EMBOSSN);
- if(lnode && (lnode->inputs.first || (lnode->typeinfo->uifunc && lnode->type != NODE_GROUP))) {
+ if (lnode && (lnode->inputs.first || (lnode->typeinfo->uifunc && lnode->type != NODE_GROUP))) {
int icon = (input->flag & SOCK_COLLAPSED)? ICON_DISCLOSURE_TRI_RIGHT: ICON_DISCLOSURE_TRI_DOWN;
uiItemR(row, &inputptr, "show_expanded", UI_ITEM_R_ICON_ONLY, "", icon);
}
@@ -606,16 +606,16 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
bt= block->buttons.last;
bt->flag= UI_TEXT_LEFT;
- if(dependency_loop) {
+ if (dependency_loop) {
row = uiLayoutRow(split, 0);
uiItemL(row, "Dependency Loop", ICON_ERROR);
}
- else if(lnode) {
+ else if (lnode) {
/* input linked to a node */
uiTemplateNodeLink(split, ntree, node, input);
- if(!(input->flag & SOCK_COLLAPSED)) {
- if(depth == 0)
+ if (!(input->flag & SOCK_COLLAPSED)) {
+ if (depth == 0)
uiItemS(layout);
ui_node_draw_node(layout, C, ntree, lnode, depth);
@@ -623,8 +623,8 @@ static void ui_node_draw_input(uiLayout *layout, bContext *C, bNodeTree *ntree,
}
else {
/* input not linked, show value */
- if(input->type != SOCK_SHADER && !(input->flag & SOCK_HIDE_VALUE)) {
- if(input->type == SOCK_VECTOR) {
+ if (input->type != SOCK_SHADER && !(input->flag & SOCK_HIDE_VALUE)) {
+ if (input->type == SOCK_VECTOR) {
row = uiLayoutRow(split, 0);
col = uiLayoutColumn(row, 0);
@@ -649,14 +649,14 @@ void uiTemplateNodeView(uiLayout *layout, bContext *C, bNodeTree *ntree, bNode *
{
bNode *tnode;
- if(!ntree)
+ if (!ntree)
return;
/* clear for cycle check */
- for(tnode=ntree->nodes.first; tnode; tnode=tnode->next)
+ for (tnode=ntree->nodes.first; tnode; tnode=tnode->next)
tnode->flag &= ~NODE_TEST;
- if(input)
+ if (input)
ui_node_draw_input(layout, C, ntree, node, input, 0);
else
ui_node_draw_node(layout, C, ntree, node, 0);