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
parent735515a3f9e4c41738bf714d682b13db64adb638 (diff)
Cleanup: style, use braces for nodes
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/composite/node_composite_tree.c36
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_cryptomatte.c3
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.c33
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_moviedistortion.c12
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_outputFile.c24
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_switchview.c24
-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
-rw-r--r--source/blender/nodes/shader/node_shader_tree.c27
-rw-r--r--source/blender/nodes/shader/node_shader_util.c63
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_common.c21
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_invert.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_mapping.c24
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c121
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_normal_map.c15
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_script.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c9
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tangent.c9
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_environment.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_image.c6
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_tex_sky.c3
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_vectTransform.c12
-rw-r--r--source/blender/nodes/texture/node_texture_tree.c36
-rw-r--r--source/blender/nodes/texture/node_texture_util.c12
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_common.c9
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_compose.c3
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_curves.c3
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_hueSatVal.c18
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_image.c18
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_math.c61
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_mixRgb.c3
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_output.c21
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_proc.c9
45 files changed, 605 insertions, 294 deletions
diff --git a/source/blender/nodes/composite/node_composite_tree.c b/source/blender/nodes/composite/node_composite_tree.c
index 70f287134d1..fd6435312b9 100644
--- a/source/blender/nodes/composite/node_composite_tree.c
+++ b/source/blender/nodes/composite/node_composite_tree.c
@@ -89,8 +89,9 @@ static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node)
static void free_cache(bNodeTree *ntree)
{
bNode *node;
- for (node = ntree->nodes.first; node; node = node->next)
+ for (node = ntree->nodes.first; node; node = node->next) {
free_node_cache(ntree, node);
+ }
}
/* local tree then owns all compbufs */
@@ -109,10 +110,12 @@ static void localize(bNodeTree *UNUSED(localtree), bNodeTree *ntree)
if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) {
if (node->id) {
- if (node->flag & NODE_DO_OUTPUT)
+ if (node->flag & NODE_DO_OUTPUT) {
node->new_node->id = (ID *)node->id;
- else
+ }
+ else {
node->new_node->id = NULL;
+ }
}
}
@@ -150,8 +153,9 @@ static void local_merge(Main *bmain, bNodeTree *localtree, bNodeTree *ntree)
* and to achieve much better performance on further calls this context should be
* copied back to original node */
if (lnode->storage) {
- if (lnode->new_node->storage)
+ if (lnode->new_node->storage) {
BKE_tracking_distortion_free(lnode->new_node->storage);
+ }
lnode->new_node->storage = BKE_tracking_distortion_copy(lnode->storage);
}
@@ -253,12 +257,14 @@ void ntreeCompositUpdateRLayers(bNodeTree *ntree)
{
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_R_LAYERS)
+ if (node->type == CMP_NODE_R_LAYERS) {
node_cmp_rlayers_outputs(ntree, node);
+ }
}
}
@@ -267,12 +273,14 @@ void ntreeCompositRegisterPass(
{
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
- if (node->type == CMP_NODE_R_LAYERS)
+ if (node->type == CMP_NODE_R_LAYERS) {
node_cmp_rlayers_register_pass(ntree, node, scene, view_layer, name, type);
+ }
}
}
@@ -290,10 +298,12 @@ void ntreeCompositTagRender(Scene *curscene)
bNode *node;
for (node = sce->nodetree->nodes.first; node; node = node->next) {
- if (node->id == (ID *)curscene || node->type == CMP_NODE_COMPOSITE)
+ if (node->id == (ID *)curscene || node->type == CMP_NODE_COMPOSITE) {
nodeUpdate(sce->nodetree, node);
- else if (node->type == CMP_NODE_TEXTURE) /* uses scene sizex/sizey */
+ }
+ else if (node->type == CMP_NODE_TEXTURE) /* uses scene sizex/sizey */ {
nodeUpdate(sce->nodetree, node);
+ }
}
}
}
@@ -304,12 +314,14 @@ void ntreeCompositClearTags(bNodeTree *ntree)
{
bNode *node;
- if (ntree == NULL)
+ if (ntree == NULL) {
return;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
node->need_exec = 0;
- if (node->type == NODE_GROUP)
+ if (node->type == NODE_GROUP) {
ntreeCompositClearTags((bNodeTree *)node->id);
+ }
}
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
index 729252f0937..e4c9b8dd0cd 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.c
@@ -276,8 +276,9 @@ static void node_copy_cryptomatte(bNodeTree *UNUSED(dest_ntree), bNode *dest_nod
NodeCryptomatte *src_nc = src_node->storage;
NodeCryptomatte *dest_nc = MEM_dupallocN(src_nc);
- if (src_nc->matte_id)
+ if (src_nc->matte_id) {
dest_nc->matte_id = MEM_dupallocN(src_nc->matte_id);
+ }
dest_node->storage = dest_nc;
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.c b/source/blender/nodes/composite/nodes/node_composite_image.c
index d4278b3b540..a1649d9f8f0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.c
+++ b/source/blender/nodes/composite/nodes/node_composite_image.c
@@ -90,8 +90,9 @@ static void cmp_node_image_add_pass_output(bNodeTree *ntree,
* Any dynamically allocated sockets follow afterwards, and are sorted in the order in which they were stored in the RenderResult.
* Therefore, we remember the index of the last matched socket. New sockets are placed behind the previously traversed one, but always after the first 31. */
int after_index = *prev_index;
- if (is_rlayers && after_index < 30)
+ if (is_rlayers && after_index < 30) {
after_index = 30;
+ }
if (rres_index >= 0) {
sock = node_add_socket_from_template(
@@ -158,10 +159,12 @@ static void cmp_node_image_create_outputs(bNodeTree *ntree,
RenderPass *rpass;
for (rpass = rl->passes.first; rpass; rpass = rpass->next) {
int type;
- if (rpass->channels == 1)
+ if (rpass->channels == 1) {
type = SOCK_FLOAT;
- else
+ }
+ else {
type = SOCK_RGBA;
+ }
cmp_node_image_add_pass_output(ntree,
node,
@@ -345,10 +348,12 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
int sock_index;
/* XXX make callback */
- if (rlayer)
+ if (rlayer) {
cmp_node_rlayer_create_outputs(ntree, node, &available_sockets);
- else
+ }
+ else {
cmp_node_image_create_outputs(ntree, node, &available_sockets);
+ }
/* Get rid of sockets whose passes are not available in the image.
* If sockets that are not available would be deleted, the connections to them would be lost
@@ -368,8 +373,9 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
else {
bNodeLink *link;
for (link = ntree->links.first; link; link = link->next) {
- if (link->fromsock == sock)
+ if (link->fromsock == sock) {
break;
+ }
}
if (!link && (!rlayer || sock_index > 30)) {
MEM_freeN(sock->storage);
@@ -387,8 +393,9 @@ static void cmp_node_image_verify_outputs(bNodeTree *ntree, bNode *node, bool rl
static void cmp_node_image_update(bNodeTree *ntree, bNode *node)
{
/* avoid unnecessary updates, only changes to the image/image user data are of interest */
- if (node->update & NODE_UPDATE_ID)
+ if (node->update & NODE_UPDATE_ID) {
cmp_node_image_verify_outputs(ntree, node, false);
+ }
cmp_node_update_default(ntree, node);
}
@@ -411,8 +418,9 @@ static void node_composit_free_image(bNode *node)
bNodeSocket *sock;
/* free extra socket info */
- for (sock = node->outputs.first; sock; sock = sock->next)
+ for (sock = node->outputs.first; sock; sock = sock->next) {
MEM_freeN(sock->storage);
+ }
MEM_freeN(node->storage);
}
@@ -426,8 +434,9 @@ static void node_composit_copy_image(bNodeTree *UNUSED(dest_ntree),
dest_node->storage = MEM_dupallocN(src_node->storage);
/* copy extra socket info */
- for (sock = src_node->outputs.first; sock; sock = sock->next)
+ for (sock = src_node->outputs.first; sock; sock = sock->next) {
sock->new_sock->storage = MEM_dupallocN(sock->storage);
+ }
}
void register_node_type_cmp_image(void)
@@ -518,9 +527,11 @@ static bool node_composit_poll_rlayers(bNodeType *UNUSED(ntype), bNodeTree *ntre
* Render layers node can only be used in local scene->nodetree,
* since it directly links to the scene.
*/
- for (scene = G.main->scenes.first; scene; scene = scene->id.next)
- if (scene->nodetree == ntree)
+ for (scene = G.main->scenes.first; scene; scene = scene->id.next) {
+ if (scene->nodetree == ntree) {
break;
+ }
+ }
return (scene != NULL);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
index 144fe5c44aa..d4462d937ad 100644
--- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
+++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.c
@@ -39,10 +39,12 @@ static bNodeSocketTemplate cmp_node_moviedistortion_out[] = {
static void label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen)
{
- if (node->custom1 == 0)
+ if (node->custom1 == 0) {
BLI_strncpy(label, IFACE_("Undistortion"), maxlen);
- else
+ }
+ else {
BLI_strncpy(label, IFACE_("Distortion"), maxlen);
+ }
}
static void init(const bContext *C, PointerRNA *ptr)
@@ -55,16 +57,18 @@ static void init(const bContext *C, PointerRNA *ptr)
static void storage_free(bNode *node)
{
- if (node->storage)
+ if (node->storage) {
BKE_tracking_distortion_free(node->storage);
+ }
node->storage = NULL;
}
static void storage_copy(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bNode *src_node)
{
- if (src_node->storage)
+ if (src_node->storage) {
dest_node->storage = BKE_tracking_distortion_copy(src_node->storage);
+ }
}
void register_node_type_cmp_moviedistortion(void)
diff --git a/source/blender/nodes/composite/nodes/node_composite_outputFile.c b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
index 624065fa96d..806a05757d0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_outputFile.c
+++ b/source/blender/nodes/composite/nodes/node_composite_outputFile.c
@@ -46,8 +46,9 @@ static bool unique_path_unique_check(void *arg, const char *name)
for (sock = data->lb->first; sock; sock = sock->next) {
if (sock != data->sock) {
NodeImageMultiFileSocket *sockdata = sock->storage;
- if (STREQ(sockdata->path, name))
+ if (STREQ(sockdata->path, name)) {
return true;
+ }
}
}
return false;
@@ -66,8 +67,9 @@ void ntreeCompositOutputFileUniquePath(ListBase *list,
data.sock = sock;
/* See if we are given an empty string */
- if (ELEM(NULL, sock, defname))
+ if (ELEM(NULL, sock, defname)) {
return;
+ }
sockdata = sock->storage;
BLI_uniquename_cb(
@@ -85,8 +87,9 @@ static bool unique_layer_unique_check(void *arg, const char *name)
for (sock = data->lb->first; sock; sock = sock->next) {
if (sock != data->sock) {
NodeImageMultiFileSocket *sockdata = sock->storage;
- if (STREQ(sockdata->layer, name))
+ if (STREQ(sockdata->layer, name)) {
return true;
+ }
}
}
return false;
@@ -105,8 +108,9 @@ void ntreeCompositOutputFileUniqueLayer(ListBase *list,
data.sock = sock;
/* See if we are given an empty string */
- if (ELEM(NULL, sock, defname))
+ if (ELEM(NULL, sock, defname)) {
return;
+ }
sockdata = sock->storage;
BLI_uniquename_cb(
@@ -137,8 +141,9 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree,
sockdata->format.imtype = R_IMF_IMTYPE_OPENEXR;
}
}
- else
+ else {
BKE_imformat_defaults(&sockdata->format);
+ }
/* use node data format by default */
sockdata->use_node_format = true;
@@ -153,11 +158,13 @@ int ntreeCompositOutputFileRemoveActiveSocket(bNodeTree *ntree, bNode *node)
bNodeSocket *sock = BLI_findlink(&node->inputs, nimf->active_input);
int totinputs = BLI_listbase_count(&node->inputs);
- if (!sock)
+ if (!sock) {
return 0;
+ }
- if (nimf->active_input == totinputs - 1)
+ if (nimf->active_input == totinputs - 1) {
--nimf->active_input;
+ }
/* free format data */
MEM_freeN(sock->storage);
@@ -201,8 +208,9 @@ static void init_output_file(const bContext *C, PointerRNA *ptr)
format = &nimf->format;
}
- else
+ else {
BKE_imformat_defaults(&nimf->format);
+ }
/* add one socket by default */
ntreeCompositOutputFileAddSocket(ntree, node, "Image", format);
diff --git a/source/blender/nodes/composite/nodes/node_composite_switchview.c b/source/blender/nodes/composite/nodes/node_composite_switchview.c
index 483185fa76b..f61c6bdd83b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_switchview.c
+++ b/source/blender/nodes/composite/nodes/node_composite_switchview.c
@@ -43,8 +43,9 @@ static void cmp_node_switch_view_sanitycheck(bNodeTree *ntree, bNode *node)
{
bNodeSocket *sock;
- if (!BLI_listbase_is_empty(&node->inputs))
+ if (!BLI_listbase_is_empty(&node->inputs)) {
return;
+ }
sock = ntreeCompositSwitchViewAddSocket(ntree, node, "No View");
sock->flag |= SOCK_HIDDEN;
@@ -57,8 +58,9 @@ static void cmp_node_switch_view_update(bNodeTree *ntree, bNode *node)
Scene *scene = (Scene *)node->id;
/* only update when called from the operator button */
- if (node->update != NODE_UPDATE_OPERATOR)
+ if (node->update != NODE_UPDATE_OPERATOR) {
return;
+ }
if (scene == NULL) {
nodeRemoveAllSockets(ntree, node);
@@ -78,10 +80,12 @@ static void cmp_node_switch_view_update(bNodeTree *ntree, bNode *node)
nodeRemoveSocket(ntree, node, sock_del);
}
else {
- if (srv->viewflag & SCE_VIEW_DISABLE)
+ if (srv->viewflag & SCE_VIEW_DISABLE) {
sock->flag |= SOCK_HIDDEN;
- else
+ }
+ else {
sock->flag &= ~SOCK_HIDDEN;
+ }
sock = sock->prev;
}
@@ -91,13 +95,16 @@ static void cmp_node_switch_view_update(bNodeTree *ntree, bNode *node)
for (srv = scene->r.views.first; srv; srv = srv->next) {
sock = BLI_findstring(&node->inputs, srv->name, offsetof(bNodeSocket, name));
- if (sock == NULL)
+ if (sock == NULL) {
sock = ntreeCompositSwitchViewAddSocket(ntree, node, srv->name);
+ }
- if (srv->viewflag & SCE_VIEW_DISABLE)
+ if (srv->viewflag & SCE_VIEW_DISABLE) {
sock->flag |= SOCK_HIDDEN;
- else
+ }
+ else {
sock->flag &= ~SOCK_HIDDEN;
+ }
}
/* make sure there is always one socket */
@@ -122,8 +129,9 @@ static void init_switch_view(const bContext *C, PointerRNA *ptr)
for (nr = 0, srv = rd->views.first; srv; srv = srv->next, nr++) {
sock = ntreeCompositSwitchViewAddSocket(ntree, node, srv->name);
- if ((srv->viewflag & SCE_VIEW_DISABLE))
+ if ((srv->viewflag & SCE_VIEW_DISABLE)) {
sock->flag |= SOCK_HIDDEN;
+ }
}
}
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 ****/
diff --git a/source/blender/nodes/shader/node_shader_tree.c b/source/blender/nodes/shader/node_shader_tree.c
index 816c56713d0..ed531a092ca 100644
--- a/source/blender/nodes/shader/node_shader_tree.c
+++ b/source/blender/nodes/shader/node_shader_tree.c
@@ -408,8 +408,9 @@ static void ntree_shader_unlink_hidden_value_sockets(bNode *group_node, bNodeSoc
for (node = group_ntree->nodes.first; node; node = node->next) {
for (bNodeSocket *sock = node->inputs.first; sock; sock = sock->next) {
- if ((sock->flag & SOCK_HIDE_VALUE) == 0)
+ if ((sock->flag & SOCK_HIDE_VALUE) == 0) {
continue;
+ }
/* If socket is linked to a group input node and sockets id match. */
if (sock && sock->link && sock->link->fromnode->type == NODE_GROUP_INPUT) {
if (STREQ(isock->identifier, sock->link->fromsock->identifier)) {
@@ -439,16 +440,18 @@ static void ntree_shader_groups_expand_inputs(bNodeTree *localtree)
for (group_node = localtree->nodes.first; group_node; group_node = group_node->next) {
- if (!(ELEM(group_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) || group_node->id == NULL)
+ if (!(ELEM(group_node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) || group_node->id == NULL) {
continue;
+ }
/* Do it recursively. */
ntree_shader_groups_expand_inputs((bNodeTree *)group_node->id);
bNodeSocket *group_socket = group_node->inputs.first;
for (; group_socket; group_socket = group_socket->next) {
- if (group_socket->link != NULL)
+ if (group_socket->link != NULL) {
continue;
+ }
/* Detect the case where an input is plugged into a hidden value socket.
* In this case we should just remove the link to trigger the socket default override. */
@@ -574,8 +577,9 @@ static void ntree_shader_link_builtin_group_normal(bNodeTree *ntree,
/* Need to update tree so all node instances nodes gets proper sockets. */
bNode *group_input_node = ntreeFindType(group_ntree, NODE_GROUP_INPUT);
node_group_verify(ntree, group_node, &group_ntree->id);
- if (group_input_node)
+ if (group_input_node) {
node_group_input_verify(group_ntree, group_input_node, &group_ntree->id);
+ }
ntreeUpdateTree(G.main, group_ntree);
/* Assumes sockets are always added at the end. */
bNodeSocket *group_node_normal_socket = group_node->inputs.last;
@@ -849,8 +853,9 @@ bNodeTreeExec *ntreeShaderBeginExecTree_internal(bNodeExecContext *context,
/* allocate the thread stack listbase array */
exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array");
- for (node = exec->nodetree->nodes.first; node; node = node->next)
+ for (node = exec->nodetree->nodes.first; node; node = node->next) {
node->need_exec = 1;
+ }
return exec;
}
@@ -863,8 +868,9 @@ bNodeTreeExec *ntreeShaderBeginExecTree(bNodeTree *ntree)
/* XXX hack: prevent exec data from being generated twice.
* this should be handled by the renderer!
*/
- if (ntree->execdata)
+ if (ntree->execdata) {
return ntree->execdata;
+ }
context.previews = ntree->previews;
@@ -885,9 +891,11 @@ void ntreeShaderEndExecTree_internal(bNodeTreeExec *exec)
if (exec->threadstack) {
for (a = 0; a < BLENDER_MAX_THREADS; a++) {
- for (nts = exec->threadstack[a].first; nts; nts = nts->next)
- if (nts->stack)
+ for (nts = exec->threadstack[a].first; nts; nts = nts->next) {
+ if (nts->stack) {
MEM_freeN(nts->stack);
+ }
+ }
BLI_freelistN(&exec->threadstack[a]);
}
@@ -921,8 +929,9 @@ bool ntreeShaderExecTree(bNodeTree *ntree, int thread)
/* ensure execdata is only initialized once */
if (!exec) {
BLI_thread_lock(LOCK_NODES);
- if (!ntree->execdata)
+ if (!ntree->execdata) {
ntree->execdata = ntreeShaderBeginExecTree(ntree);
+ }
BLI_thread_unlock(LOCK_NODES);
exec = ntree->execdata;
diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c
index a29962843af..e75cb8a6642 100644
--- a/source/blender/nodes/shader/node_shader_util.c
+++ b/source/blender/nodes/shader/node_shader_util.c
@@ -49,10 +49,12 @@ void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
const float *from = ns->vec;
if (type_in == SOCK_FLOAT) {
- if (ns->sockettype == SOCK_FLOAT)
+ if (ns->sockettype == SOCK_FLOAT) {
*in = *from;
- else
+ }
+ else {
*in = (from[0] + from[1] + from[2]) / 3.0f;
+ }
}
else if (type_in == SOCK_VECTOR) {
if (ns->sockettype == SOCK_FLOAT) {
@@ -98,18 +100,24 @@ void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, bNodeStack *ns)
nodestack_get_vec(gs->vec, type, ns);
gs->link = ns->data;
- if (type == SOCK_FLOAT)
+ if (type == SOCK_FLOAT) {
gs->type = GPU_FLOAT;
- else if (type == SOCK_INT)
+ }
+ else if (type == SOCK_INT) {
gs->type = GPU_FLOAT; /* HACK: Support as float. */
- else if (type == SOCK_VECTOR)
+ }
+ else if (type == SOCK_VECTOR) {
gs->type = GPU_VEC3;
- else if (type == SOCK_RGBA)
+ }
+ else if (type == SOCK_RGBA) {
gs->type = GPU_VEC4;
- else if (type == SOCK_SHADER)
+ }
+ else if (type == SOCK_SHADER) {
gs->type = GPU_CLOSURE;
- else
+ }
+ else {
gs->type = GPU_NONE;
+ }
gs->hasinput = ns->hasinput && ns->data;
/* XXX Commented out the ns->data check here, as it seems it's not always set,
@@ -133,8 +141,9 @@ static void gpu_stack_from_data_list(GPUNodeStack *gs, ListBase *sockets, bNodeS
bNodeSocket *sock;
int i;
- for (sock = sockets->first, i = 0; sock; sock = sock->next, i++)
+ for (sock = sockets->first, i = 0; sock; sock = sock->next, i++) {
node_gpu_stack_from_data(&gs[i], sock->type, ns[i]);
+ }
gs[i].end = true;
}
@@ -144,8 +153,9 @@ static void data_from_gpu_stack_list(ListBase *sockets, bNodeStack **ns, GPUNode
bNodeSocket *sock;
int i;
- for (sock = sockets->first, i = 0; sock; sock = sock->next, i++)
+ for (sock = sockets->first, i = 0; sock; sock = sock->next, i++) {
node_data_from_gpu_stack(ns[i], &gs[i]);
+ }
}
bNode *nodeGetActiveTexture(bNodeTree *ntree)
@@ -154,23 +164,28 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
bNode *node, *tnode, *inactivenode = NULL, *activetexnode = NULL, *activegroup = NULL;
bool hasgroup = false;
- if (!ntree)
+ if (!ntree) {
return NULL;
+ }
for (node = ntree->nodes.first; node; node = node->next) {
if (node->flag & NODE_ACTIVE_TEXTURE) {
activetexnode = node;
/* if active we can return immediately */
- if (node->flag & NODE_ACTIVE)
+ if (node->flag & NODE_ACTIVE) {
return node;
+ }
}
- else if (!inactivenode && node->typeinfo->nclass == NODE_CLASS_TEXTURE)
+ else if (!inactivenode && node->typeinfo->nclass == NODE_CLASS_TEXTURE) {
inactivenode = node;
+ }
else if (node->type == NODE_GROUP) {
- if (node->flag & NODE_ACTIVE)
+ if (node->flag & NODE_ACTIVE) {
activegroup = node;
- else
+ }
+ else {
hasgroup = true;
+ }
}
}
@@ -178,20 +193,23 @@ bNode *nodeGetActiveTexture(bNodeTree *ntree)
if (activegroup) {
tnode = nodeGetActiveTexture((bNodeTree *)activegroup->id);
/* active node takes priority, so ignore any other possible nodes here */
- if (tnode)
+ if (tnode) {
return tnode;
+ }
}
- if (activetexnode)
+ if (activetexnode) {
return activetexnode;
+ }
if (hasgroup) {
/* node active texture node in this tree, look inside groups */
for (node = ntree->nodes.first; node; node = node->next) {
if (node->type == NODE_GROUP) {
tnode = nodeGetActiveTexture((bNodeTree *)node->id);
- if (tnode && ((tnode->flag & NODE_ACTIVE_TEXTURE) || !inactivenode))
+ if (tnode && ((tnode->flag & NODE_ACTIVE_TEXTURE) || !inactivenode)) {
return tnode;
+ }
}
}
}
@@ -218,8 +236,9 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node
do_it = false;
/* for groups, only execute outputs for edited group */
if (node->typeinfo->nclass == NODE_CLASS_OUTPUT) {
- if ((output_node != NULL) && (node == output_node))
+ if ((output_node != NULL) && (node == output_node)) {
do_it = true;
+ }
}
else {
do_it = true;
@@ -230,8 +249,9 @@ void ntreeExecGPUNodes(bNodeTreeExec *exec, GPUMaterial *mat, bNode *output_node
node_get_stack(node, stack, nsin, nsout);
gpu_stack_from_data_list(gpuin, &node->inputs, nsin);
gpu_stack_from_data_list(gpuout, &node->outputs, nsout);
- if (node->typeinfo->gpufunc(mat, node, &nodeexec->data, gpuin, gpuout))
+ if (node->typeinfo->gpufunc(mat, node, &nodeexec->data, gpuin, gpuout)) {
data_from_gpu_stack_list(&node->outputs, nsout, gpuout);
+ }
}
}
}
@@ -261,7 +281,8 @@ void node_shader_gpu_tex_mapping(GPUMaterial *mat,
GPU_link(mat, "mapping", in[0].link, tmat0, tmat1, tmat2, tmat3, tmin, tmax, &in[0].link);
- if (texmap->type == TEXMAP_TYPE_NORMAL)
+ if (texmap->type == TEXMAP_TYPE_NORMAL) {
GPU_link(mat, "texco_norm", in[0].link, &in[0].link);
+ }
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
index 84dda89c47d..f54d2563623 100644
--- a/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
+++ b/source/blender/nodes/shader/nodes/node_shader_ambient_occlusion.c
@@ -50,8 +50,9 @@ static int node_shader_gpu_ambient_occlusion(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[2].link)
+ if (!in[2].link) {
GPU_link(mat, "world_normals_get", &in[2].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
index dc92af5ee48..117c903a161 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_anisotropic.c
@@ -67,8 +67,9 @@ static int node_shader_gpu_bsdf_anisotropic(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[4].link)
+ if (!in[4].link) {
GPU_link(mat, "world_normals_get", &in[4].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
index 5ed02a275f1..5d1a8d0990a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_diffuse.c
@@ -49,8 +49,9 @@ static int node_shader_gpu_bsdf_diffuse(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[2].link)
+ if (!in[2].link) {
GPU_link(mat, "world_normals_get", &in[2].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
index 682fddc1f9d..ffeda75d366 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glass.c
@@ -55,8 +55,9 @@ static int node_shader_gpu_bsdf_glass(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[3].link)
+ if (!in[3].link) {
GPU_link(mat, "world_normals_get", &in[3].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY | GPU_MATFLAG_REFRACT);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
index 97c1afbbee2..9200a6c468c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_glossy.c
@@ -54,11 +54,13 @@ static int node_shader_gpu_bsdf_glossy(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[2].link)
+ if (!in[2].link) {
GPU_link(mat, "world_normals_get", &in[2].link);
+ }
- if (node->custom1 == SHD_GLOSSY_SHARP)
+ if (node->custom1 == SHD_GLOSSY_SHARP) {
GPU_link(mat, "set_value_zero", &in[1].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_GLOSSY);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
index e0fda117648..b45249e11b2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c
@@ -196,10 +196,12 @@ static void node_shader_update_principled(bNodeTree *UNUSED(ntree), bNode *node)
for (sock = node->inputs.first; sock; sock = sock->next) {
if (STREQ(sock->name, "Transmission Roughness")) {
- if (distribution == SHD_GLOSSY_GGX)
+ if (distribution == SHD_GLOSSY_GGX) {
sock->flag &= ~SOCK_UNAVAIL;
- else
+ }
+ else {
sock->flag |= SOCK_UNAVAIL;
+ }
}
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
index 2d740cab776..4d98c62f95c 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_refraction.c
@@ -55,11 +55,13 @@ static int node_shader_gpu_bsdf_refraction(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[3].link)
+ if (!in[3].link) {
GPU_link(mat, "world_normals_get", &in[3].link);
+ }
- if (node->custom1 == SHD_GLOSSY_SHARP)
+ if (node->custom1 == SHD_GLOSSY_SHARP) {
GPU_link(mat, "set_value_zero", &in[1].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_REFRACT);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
index 8ec80be748e..b5faf1df913 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_toon.c
@@ -50,8 +50,9 @@ static int node_shader_gpu_bsdf_toon(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[3].link)
+ if (!in[3].link) {
GPU_link(mat, "world_normals_get", &in[3].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
index 6e2556d7446..993a5b3d945 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_translucent.c
@@ -48,8 +48,9 @@ static int node_shader_gpu_bsdf_translucent(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[1].link)
+ if (!in[1].link) {
GPU_link(mat, "world_normals_get", &in[1].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
index d4cb444cf08..97c2c9bc084 100644
--- a/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
+++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_velvet.c
@@ -49,8 +49,9 @@ static int node_shader_gpu_bsdf_velvet(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[2].link)
+ if (!in[2].link) {
GPU_link(mat, "world_normals_get", &in[2].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE);
diff --git a/source/blender/nodes/shader/nodes/node_shader_common.c b/source/blender/nodes/shader/nodes/node_shader_common.c
index 3f95d31841e..64dd2f28208 100644
--- a/source/blender/nodes/shader/nodes/node_shader_common.c
+++ b/source/blender/nodes/shader/nodes/node_shader_common.c
@@ -67,8 +67,9 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc
bNodeTree *ngroup = (bNodeTree *)node->id;
bNodeTreeExec *exec;
- if (!ngroup)
+ if (!ngroup) {
return NULL;
+ }
/* initialize the internal node tree execution */
exec = ntreeShaderBeginExecTree_internal(context, ngroup, key);
@@ -80,8 +81,9 @@ static void group_freeexec(void *nodedata)
{
bNodeTreeExec *gexec = (bNodeTreeExec *)nodedata;
- if (gexec)
+ if (gexec) {
ntreeShaderEndExecTree_internal(gexec);
+ }
}
/* Copy inputs to the internal stack.
@@ -98,8 +100,9 @@ static void group_copy_inputs(bNode *gnode, bNodeStack **in, bNodeStack *gstack)
if (node->type == NODE_GROUP_INPUT) {
for (sock = node->outputs.first, a = 0; sock; sock = sock->next, ++a) {
ns = node_get_socket_stack(gstack, sock);
- if (ns)
+ if (ns) {
copy_stack(ns, in[a]);
+ }
}
}
}
@@ -119,8 +122,9 @@ static void group_move_outputs(bNode *gnode, bNodeStack **out, bNodeStack *gstac
if (node->type == NODE_GROUP_OUTPUT && (node->flag & NODE_DO_OUTPUT)) {
for (sock = node->inputs.first, a = 0; sock; sock = sock->next, ++a) {
ns = node_get_socket_stack(gstack, sock);
- if (ns)
+ if (ns) {
move_stack(out[a], ns);
+ }
}
break; /* only one active output node */
}
@@ -137,16 +141,18 @@ static void group_execute(void *data,
bNodeTreeExec *exec = execdata->data;
bNodeThreadStack *nts;
- if (!exec)
+ if (!exec) {
return;
+ }
/* XXX same behavior as trunk: all nodes inside group are executed.
* it's stupid, but just makes it work. compo redesign will do this better.
*/
{
bNode *inode;
- for (inode = exec->nodetree->nodes.first; inode; inode = inode->next)
+ for (inode = exec->nodetree->nodes.first; inode; inode = inode->next) {
inode->need_exec = 1;
+ }
}
nts = ntreeGetThreadStack(exec, thread);
@@ -208,8 +214,9 @@ static int gpu_group_execute(
{
bNodeTreeExec *exec = execdata->data;
- if (!node->id)
+ if (!node->id) {
return 0;
+ }
group_gpu_copy_inputs(node, in, exec->stack);
ntreeExecGPUNodes(exec, mat, NULL);
diff --git a/source/blender/nodes/shader/nodes/node_shader_invert.c b/source/blender/nodes/shader/nodes/node_shader_invert.c
index 802d10def0a..4a17c3432de 100644
--- a/source/blender/nodes/shader/nodes/node_shader_invert.c
+++ b/source/blender/nodes/shader/nodes/node_shader_invert.c
@@ -48,10 +48,12 @@ static void node_shader_exec_invert(void *UNUSED(data),
icol[2] = 1.0f - col[2];
/* if fac, blend result against original input */
- if (fac < 1.0f)
+ if (fac < 1.0f) {
interp_v3_v3v3(out[0]->vec, col, icol, fac);
- else
+ }
+ else {
copy_v3_v3(out[0]->vec, icol);
+ }
}
static int gpu_shader_invert(GPUMaterial *mat,
diff --git a/source/blender/nodes/shader/nodes/node_shader_mapping.c b/source/blender/nodes/shader/nodes/node_shader_mapping.c
index 5af0dd55083..eca0d96f2c8 100644
--- a/source/blender/nodes/shader/nodes/node_shader_mapping.c
+++ b/source/blender/nodes/shader/nodes/node_shader_mapping.c
@@ -60,24 +60,31 @@ static void node_shader_exec_mapping(void *UNUSED(data),
mul_m4_v3(texmap->mat, vec);
if (texmap->flag & TEXMAP_CLIP_MIN) {
- if (vec[0] < texmap->min[0])
+ if (vec[0] < texmap->min[0]) {
vec[0] = texmap->min[0];
- if (vec[1] < texmap->min[1])
+ }
+ if (vec[1] < texmap->min[1]) {
vec[1] = texmap->min[1];
- if (vec[2] < texmap->min[2])
+ }
+ if (vec[2] < texmap->min[2]) {
vec[2] = texmap->min[2];
+ }
}
if (texmap->flag & TEXMAP_CLIP_MAX) {
- if (vec[0] > texmap->max[0])
+ if (vec[0] > texmap->max[0]) {
vec[0] = texmap->max[0];
- if (vec[1] > texmap->max[1])
+ }
+ if (vec[1] > texmap->max[1]) {
vec[1] = texmap->max[1];
- if (vec[2] > texmap->max[2])
+ }
+ if (vec[2] > texmap->max[2]) {
vec[2] = texmap->max[2];
+ }
}
- if (texmap->type == TEXMAP_TYPE_NORMAL)
+ if (texmap->type == TEXMAP_TYPE_NORMAL) {
normalize_v3(vec);
+ }
}
static void node_shader_init_mapping(bNodeTree *UNUSED(ntree), bNode *node)
@@ -107,8 +114,9 @@ static int gpu_shader_mapping(GPUMaterial *mat,
GPU_stack_link(mat, node, "mapping", in, out, tmat0, tmat1, tmat2, tmat3, tmin, tmax);
- if (texmap->type == TEXMAP_TYPE_NORMAL)
+ if (texmap->type == TEXMAP_TYPE_NORMAL) {
GPU_link(mat, "texco_norm", out[0].link, &out[0].link);
+ }
return true;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c
index 6e104066a58..f8d1617887e 100644
--- a/source/blender/nodes/shader/nodes/node_shader_math.c
+++ b/source/blender/nodes/shader/nodes/node_shader_math.c
@@ -55,51 +55,66 @@ static void node_shader_exec_math(void *UNUSED(data),
r = a * b;
break;
case NODE_MATH_DIVIDE: {
- if (b == 0) /* We don't want to divide by zero. */
+ if (b == 0) { /* We don't want to divide by zero. */
r = 0.0;
- else
+ }
+ else {
r = a / b;
+ }
break;
}
case NODE_MATH_SIN: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = sinf(a);
- else
+ }
+ else {
r = sinf(b);
+ }
break;
}
case NODE_MATH_COS: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = cosf(a);
- else
+ }
+ else {
r = cosf(b);
+ }
break;
}
case NODE_MATH_TAN: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = tanf(a);
- else
+ }
+ else {
r = tanf(b);
+ }
break;
}
case NODE_MATH_ASIN: {
if (in[0]->hasinput ||
!in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
/* Can't do the impossible... */
- if (a <= 1 && a >= -1)
+ if (a <= 1 && a >= -1) {
r = asinf(a);
- else
+ }
+ else {
r = 0.0;
+ }
}
else {
/* Can't do the impossible... */
- if (b <= 1 && b >= -1)
+ if (b <= 1 && b >= -1) {
r = asinf(b);
- else
+ }
+ else {
r = 0.0;
+ }
}
break;
}
@@ -107,26 +122,33 @@ static void node_shader_exec_math(void *UNUSED(data),
if (in[0]->hasinput ||
!in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
/* Can't do the impossible... */
- if (a <= 1 && a >= -1)
+ if (a <= 1 && a >= -1) {
r = acosf(a);
- else
+ }
+ else {
r = 0.0;
+ }
}
else {
/* Can't do the impossible... */
- if (b <= 1 && b >= -1)
+ if (b <= 1 && b >= -1) {
r = acosf(b);
- else
+ }
+ else {
r = 0.0;
+ }
}
break;
}
case NODE_MATH_ATAN: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = atan(a);
- else
+ }
+ else {
r = atan(b);
+ }
break;
}
case NODE_MATH_POW: {
@@ -150,53 +172,68 @@ static void node_shader_exec_math(void *UNUSED(data),
}
case NODE_MATH_LOG: {
/* Don't want any imaginary numbers... */
- if (a > 0 && b > 0)
+ if (a > 0 && b > 0) {
r = log(a) / log(b);
- else
+ }
+ else {
r = 0.0;
+ }
break;
}
case NODE_MATH_MIN: {
- if (a < b)
+ if (a < b) {
r = a;
- else
+ }
+ else {
r = b;
+ }
break;
}
case NODE_MATH_MAX: {
- if (a > b)
+ if (a > b) {
r = a;
- else
+ }
+ else {
r = b;
+ }
break;
}
case NODE_MATH_ROUND: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = (a < 0) ? (int)(a - 0.5f) : (int)(a + 0.5f);
- else
+ }
+ else {
r = (b < 0) ? (int)(b - 0.5f) : (int)(b + 0.5f);
+ }
break;
}
case NODE_MATH_LESS: {
- if (a < b)
+ if (a < b) {
r = 1.0f;
- else
+ }
+ else {
r = 0.0f;
+ }
break;
}
case NODE_MATH_GREATER: {
- if (a > b)
+ if (a > b) {
r = 1.0f;
- else
+ }
+ else {
r = 0.0f;
+ }
break;
}
case NODE_MATH_MOD: {
- if (b == 0.0f)
+ if (b == 0.0f) {
r = 0.0f;
- else
+ }
+ else {
r = fmod(a, b);
+ }
break;
}
case NODE_MATH_ABS: {
@@ -210,40 +247,54 @@ static void node_shader_exec_math(void *UNUSED(data),
case NODE_MATH_FLOOR: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = floorf(a);
- else
+ }
+ else {
r = floorf(b);
+ }
break;
}
case NODE_MATH_CEIL: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = ceilf(a);
- else
+ }
+ else {
r = ceilf(b);
+ }
break;
}
case NODE_MATH_FRACT: {
if (in[0]->hasinput ||
!in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
r = a - floorf(a);
- else
+ }
+ else {
r = b - floorf(b);
+ }
break;
}
case NODE_MATH_SQRT: {
if (in[0]->hasinput ||
- !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */
- if (a > 0)
+ !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */
+ {
+ if (a > 0) {
r = sqrt(a);
- else
+ }
+ else {
r = 0.0;
+ }
}
else {
- if (b > 0)
+ if (b > 0) {
r = sqrt(b);
- else
+ }
+ else {
r = 0.0;
+ }
}
break;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_normal_map.c b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
index fcc64707642..d769a219fa0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_normal_map.c
+++ b/source/blender/nodes/shader/nodes/node_shader_normal_map.c
@@ -60,32 +60,37 @@ static int gpu_shader_normal_map(GPUMaterial *mat,
float d[4] = {0, 0, 0, 0};
- if (in[0].link)
+ if (in[0].link) {
strength = in[0].link;
+ }
else if (node->original) {
bNodeSocket *socket = BLI_findlink(&node->original->inputs, 0);
bNodeSocketValueFloat *socket_data = socket->default_value;
strength = GPU_uniform(&socket_data->value);
}
- else
+ else {
strength = GPU_constant(in[0].vec);
+ }
- if (in[1].link)
+ if (in[1].link) {
realnorm = in[1].link;
+ }
else if (node->original) {
bNodeSocket *socket = BLI_findlink(&node->original->inputs, 1);
bNodeSocketValueRGBA *socket_data = socket->default_value;
realnorm = GPU_uniform(socket_data->value);
}
- else
+ else {
realnorm = GPU_constant(in[1].vec);
+ }
negnorm = GPU_builtin(GPU_VIEW_NORMAL);
GPU_link(mat, "math_max", strength, GPU_constant(d), &strength);
const char *color_to_normal_fnc_name = "color_to_normal_new_shading";
- if (nm->space == SHD_SPACE_BLENDER_OBJECT || nm->space == SHD_SPACE_BLENDER_WORLD)
+ if (nm->space == SHD_SPACE_BLENDER_OBJECT || nm->space == SHD_SPACE_BLENDER_WORLD) {
color_to_normal_fnc_name = "color_to_blender_normal_new_shading";
+ }
switch (nm->space) {
case SHD_SPACE_TANGENT:
GPU_link(mat, "color_to_normal_new_shading", realnorm, &realnorm);
diff --git a/source/blender/nodes/shader/nodes/node_shader_script.c b/source/blender/nodes/shader/nodes/node_shader_script.c
index 088272bbfb4..29d3fd3ba67 100644
--- a/source/blender/nodes/shader/nodes/node_shader_script.c
+++ b/source/blender/nodes/shader/nodes/node_shader_script.c
@@ -49,8 +49,9 @@ static void node_copy_script(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, bN
NodeShaderScript *src_nss = src_node->storage;
NodeShaderScript *dest_nss = MEM_dupallocN(src_nss);
- if (src_nss->bytecode)
+ if (src_nss->bytecode) {
dest_nss->bytecode = MEM_dupallocN(src_nss->bytecode);
+ }
dest_node->storage = dest_nss;
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
index a6a2edd5352..d590f229c1a 100644
--- a/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
+++ b/source/blender/nodes/shader/nodes/node_shader_subsurface_scattering.c
@@ -57,8 +57,9 @@ static int node_shader_gpu_subsurface_scattering(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[5].link)
+ if (!in[5].link) {
GPU_link(mat, "world_normals_get", &in[5].link);
+ }
GPU_material_flag_set(mat, GPU_MATFLAG_DIFFUSE | GPU_MATFLAG_SSS);
@@ -83,10 +84,12 @@ static void node_shader_update_subsurface_scattering(bNodeTree *UNUSED(ntree), b
for (sock = node->inputs.first; sock; sock = sock->next) {
if (STREQ(sock->name, "Sharpness")) {
- if (falloff == SHD_SUBSURFACE_CUBIC)
+ if (falloff == SHD_SUBSURFACE_CUBIC) {
sock->flag &= ~SOCK_UNAVAIL;
- else
+ }
+ else {
sock->flag |= SOCK_UNAVAIL;
+ }
}
}
}
diff --git a/source/blender/nodes/shader/nodes/node_shader_tangent.c b/source/blender/nodes/shader/nodes/node_shader_tangent.c
index 6af19503800..5512754d9a2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tangent.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tangent.c
@@ -53,12 +53,15 @@ static int node_shader_gpu_tangent(GPUMaterial *mat,
else {
GPUNodeLink *orco = GPU_attribute(CD_ORCO, "");
- if (attr->axis == SHD_TANGENT_AXIS_X)
+ if (attr->axis == SHD_TANGENT_AXIS_X) {
GPU_link(mat, "tangent_orco_x", orco, &orco);
- else if (attr->axis == SHD_TANGENT_AXIS_Y)
+ }
+ else if (attr->axis == SHD_TANGENT_AXIS_Y) {
GPU_link(mat, "tangent_orco_y", orco, &orco);
- else
+ }
+ else {
GPU_link(mat, "tangent_orco_z", orco, &orco);
+ }
return GPU_stack_link(mat,
node,
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
index 0105bea9550..c3b8bc8bfd0 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_environment.c
@@ -71,8 +71,9 @@ static int node_shader_gpu_tex_environment(GPUMaterial *mat,
int isdata = tex->color_space == SHD_COLORSPACE_NONE;
GPUNodeLink *outalpha;
- if (!ima)
+ if (!ima) {
return GPU_stack_link(mat, node, "node_tex_environment_empty", in, out);
+ }
if (!in[0].link) {
GPU_link(mat, "node_tex_environment_texco", GPU_builtin(GPU_VIEW_POSITION), &in[0].link);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_image.c b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
index 37a9247c1cc..d4dcb6857d2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_image.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_image.c
@@ -115,8 +115,9 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
int isdata = tex->color_space == SHD_COLORSPACE_NONE;
float blend = tex->projection_blend;
- if (!ima)
+ if (!ima) {
return GPU_stack_link(mat, node, "node_tex_image_empty", in, out);
+ }
ImBuf *ibuf = BKE_image_acquire_ibuf(ima, iuser, NULL);
if ((tex->color_space == SHD_COLORSPACE_COLOR) && ibuf &&
@@ -126,8 +127,9 @@ static int node_shader_gpu_tex_image(GPUMaterial *mat,
}
BKE_image_release_ibuf(ima, ibuf, NULL);
- if (!in[0].link)
+ if (!in[0].link) {
in[0].link = GPU_attribute(CD_MTFACE, "");
+ }
node_shader_gpu_tex_mapping(mat, node, in, out);
diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
index 15db757a9a1..b1fb0cad4b2 100644
--- a/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
+++ b/source/blender/nodes/shader/nodes/node_shader_tex_sky.c
@@ -62,8 +62,9 @@ static int node_shader_gpu_tex_sky(GPUMaterial *mat,
GPUNodeStack *in,
GPUNodeStack *out)
{
- if (!in[0].link)
+ if (!in[0].link) {
in[0].link = GPU_attribute(CD_ORCO, "");
+ }
node_shader_gpu_tex_mapping(mat, node, in, out);
diff --git a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
index 08a53c1d53d..fe0e7b1d638 100644
--- a/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
+++ b/source/blender/nodes/shader/nodes/node_shader_vectTransform.c
@@ -104,10 +104,12 @@ static int gpu_shader_vect_transform(GPUMaterial *mat,
NodeShaderVectTransform *nodeprop = (NodeShaderVectTransform *)node->storage;
- if (in[0].hasinput)
+ if (in[0].hasinput) {
inputlink = in[0].link;
- else
+ }
+ else {
inputlink = GPU_constant(in[0].vec);
+ }
fromto = get_gpulink_matrix_from_to(nodeprop->convert_from, nodeprop->convert_to);
@@ -125,11 +127,13 @@ static int gpu_shader_vect_transform(GPUMaterial *mat,
GPU_link(mat, "invert_z", out[0].link, &out[0].link);
}
}
- else
+ else {
GPU_link(mat, "set_rgb", inputlink, &out[0].link);
+ }
- if (nodeprop->type == SHD_VECT_TRANSFORM_TYPE_NORMAL)
+ if (nodeprop->type == SHD_VECT_TRANSFORM_TYPE_NORMAL) {
GPU_link(mat, "vect_normalize", out[0].link, &out[0].link);
+ }
return true;
}
diff --git a/source/blender/nodes/texture/node_texture_tree.c b/source/blender/nodes/texture/node_texture_tree.c
index 519ae4fac9b..60630da586d 100644
--- a/source/blender/nodes/texture/node_texture_tree.c
+++ b/source/blender/nodes/texture/node_texture_tree.c
@@ -65,10 +65,12 @@ static void texture_get_from_context(const bContext *C,
if (snode->texfrom == SNODE_TEX_BRUSH) {
struct Brush *brush = NULL;
- if (ob && (ob->mode & OB_MODE_SCULPT))
+ if (ob && (ob->mode & OB_MODE_SCULPT)) {
brush = BKE_paint_brush(&scene->toolsettings->sculpt->paint);
- else
+ }
+ else {
brush = BKE_paint_brush(&scene->toolsettings->imapaint.paint);
+ }
if (brush) {
*r_from = (ID *)brush;
@@ -188,8 +190,9 @@ bNodeTreeExec *ntreeTexBeginExecTree_internal(bNodeExecContext *context,
/* allocate the thread stack listbase array */
exec->threadstack = MEM_callocN(BLENDER_MAX_THREADS * sizeof(ListBase), "thread stack array");
- for (node = exec->nodetree->nodes.first; node; node = node->next)
+ for (node = exec->nodetree->nodes.first; node; node = node->next) {
node->need_exec = 1;
+ }
return exec;
}
@@ -202,8 +205,9 @@ bNodeTreeExec *ntreeTexBeginExecTree(bNodeTree *ntree)
/* XXX hack: prevent exec data from being generated twice.
* this should be handled by the renderer!
*/
- if (ntree->execdata)
+ if (ntree->execdata) {
return ntree->execdata;
+ }
context.previews = ntree->previews;
@@ -224,11 +228,15 @@ static void tex_free_delegates(bNodeTreeExec *exec)
bNodeStack *ns;
int th, a;
- for (th = 0; th < BLENDER_MAX_THREADS; th++)
- for (nts = exec->threadstack[th].first; nts; nts = nts->next)
- for (ns = nts->stack, a = 0; a < exec->stacksize; a++, ns++)
- if (ns->data && !ns->is_copy)
+ for (th = 0; th < BLENDER_MAX_THREADS; th++) {
+ for (nts = exec->threadstack[th].first; nts; nts = nts->next) {
+ for (ns = nts->stack, a = 0; a < exec->stacksize; a++, ns++) {
+ if (ns->data && !ns->is_copy) {
MEM_freeN(ns->data);
+ }
+ }
+ }
+ }
}
void ntreeTexEndExecTree_internal(bNodeTreeExec *exec)
@@ -240,9 +248,11 @@ void ntreeTexEndExecTree_internal(bNodeTreeExec *exec)
tex_free_delegates(exec);
for (a = 0; a < BLENDER_MAX_THREADS; a++) {
- for (nts = exec->threadstack[a].first; nts; nts = nts->next)
- if (nts->stack)
+ for (nts = exec->threadstack[a].first; nts; nts = nts->next) {
+ if (nts->stack) {
MEM_freeN(nts->stack);
+ }
+ }
BLI_freelistN(&exec->threadstack[a]);
}
@@ -299,8 +309,9 @@ int ntreeTexExecTree(bNodeTree *nodes,
/* ensure execdata is only initialized once */
if (!exec) {
BLI_thread_lock(LOCK_NODES);
- if (!nodes->execdata)
+ if (!nodes->execdata) {
ntreeTexBeginExecTree(nodes);
+ }
BLI_thread_unlock(LOCK_NODES);
exec = nodes->execdata;
@@ -310,8 +321,9 @@ int ntreeTexExecTree(bNodeTree *nodes,
ntreeExecThreadNodes(exec, nts, &data, thread);
ntreeReleaseThreadStack(nts);
- if (texres->nor)
+ if (texres->nor) {
retval |= TEX_NOR;
+ }
retval |= TEX_RGB;
/* confusing stuff; the texture output node sets this to NULL to indicate no normal socket was set
* however, the texture code checks this for other reasons (namely, a normal is required for material) */
diff --git a/source/blender/nodes/texture/node_texture_util.c b/source/blender/nodes/texture/node_texture_util.c
index ba65a692835..844a45f8d8b 100644
--- a/source/blender/nodes/texture/node_texture_util.c
+++ b/source/blender/nodes/texture/node_texture_util.c
@@ -60,8 +60,9 @@ static void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, sh
if (dg->node->need_exec) {
dg->fn(out, params, dg->node, dg->in, thread);
- if (dg->cdata->do_preview)
+ if (dg->cdata->do_preview) {
tex_do_preview(dg->preview, params->previewco, out, dg->cdata->do_manage);
+ }
}
}
@@ -71,8 +72,9 @@ static void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, sho
if (dg) {
tex_call_delegate(dg, in->vec, params, thread);
- if (in->hasoutput && in->sockettype == SOCK_FLOAT)
+ if (in->hasoutput && in->sockettype == SOCK_FLOAT) {
in->vec[1] = in->vec[2] = in->vec[0];
+ }
}
memcpy(out, in->vec, sz * sizeof(float));
}
@@ -144,11 +146,13 @@ void tex_output(bNode *node,
return;
}
else {
- if (!out->data)
+ if (!out->data) {
/* Freed in tex_end_exec (node.c) */
dg = out->data = MEM_mallocN(sizeof(TexDelegate), "tex delegate");
- else
+ }
+ else {
dg = out->data;
+ }
}
dg->cdata = cdata;
diff --git a/source/blender/nodes/texture/nodes/node_texture_common.c b/source/blender/nodes/texture/nodes/node_texture_common.c
index 9f76c464c12..929bf92dec3 100644
--- a/source/blender/nodes/texture/nodes/node_texture_common.c
+++ b/source/blender/nodes/texture/nodes/node_texture_common.c
@@ -54,8 +54,9 @@ static void *group_initexec(bNodeExecContext *context, bNode *node, bNodeInstanc
bNodeTree *ngroup = (bNodeTree *)node->id;
void *exec;
- if (!ngroup)
+ if (!ngroup) {
return NULL;
+ }
/* initialize the internal node tree execution */
exec = ntreeTexBeginExecTree_internal(context, ngroup, key);
@@ -130,16 +131,18 @@ static void group_execute(void *data,
bNodeTreeExec *exec = execdata->data;
bNodeThreadStack *nts;
- if (!exec)
+ if (!exec) {
return;
+ }
/* XXX same behavior as trunk: all nodes inside group are executed.
* it's stupid, but just makes it work. compo redesign will do this better.
*/
{
bNode *inode;
- for (inode = exec->nodetree->nodes.first; inode; inode = inode->next)
+ for (inode = exec->nodetree->nodes.first; inode; inode = inode->next) {
inode->need_exec = 1;
+ }
}
nts = ntreeGetThreadStack(exec, thread);
diff --git a/source/blender/nodes/texture/nodes/node_texture_compose.c b/source/blender/nodes/texture/nodes/node_texture_compose.c
index ae266451671..3c9791578fd 100644
--- a/source/blender/nodes/texture/nodes/node_texture_compose.c
+++ b/source/blender/nodes/texture/nodes/node_texture_compose.c
@@ -39,8 +39,9 @@ static bNodeSocketTemplate outputs[] = {
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
{
int i;
- for (i = 0; i < 4; i++)
+ for (i = 0; i < 4; i++) {
out[i] = tex_input_value(in[i], p, thread);
+ }
}
static void exec(void *data,
diff --git a/source/blender/nodes/texture/nodes/node_texture_curves.c b/source/blender/nodes/texture/nodes/node_texture_curves.c
index a57e2d8f35f..1087d05d040 100644
--- a/source/blender/nodes/texture/nodes/node_texture_curves.c
+++ b/source/blender/nodes/texture/nodes/node_texture_curves.c
@@ -35,8 +35,9 @@ static void time_colorfn(
/* stack order output: fac */
float fac = 0.0f;
- if (node->custom1 < node->custom2)
+ if (node->custom1 < node->custom2) {
fac = (p->cfra - node->custom1) / (float)(node->custom2 - node->custom1);
+ }
curvemapping_initialize(node->storage);
fac = curvemapping_evaluateF(node->storage, 0, fac);
diff --git a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
index c4105083945..513b0bdd647 100644
--- a/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
+++ b/source/blender/nodes/texture/nodes/node_texture_hueSatVal.c
@@ -45,20 +45,26 @@ static void do_hue_sat_fac(
rgb_to_hsv(in[0], in[1], in[2], hsv, hsv + 1, hsv + 2);
hsv[0] += (hue - 0.5f);
- if (hsv[0] > 1.0f)
+ if (hsv[0] > 1.0f) {
hsv[0] -= 1.0f;
- else if (hsv[0] < 0.0f)
+ }
+ else if (hsv[0] < 0.0f) {
hsv[0] += 1.0f;
+ }
hsv[1] *= sat;
- if (hsv[1] > 1.0f)
+ if (hsv[1] > 1.0f) {
hsv[1] = 1.0f;
- else if (hsv[1] < 0.0f)
+ }
+ else if (hsv[1] < 0.0f) {
hsv[1] = 0.0f;
+ }
hsv[2] *= val;
- if (hsv[2] > 1.0f)
+ if (hsv[2] > 1.0f) {
hsv[2] = 1.0f;
- else if (hsv[2] < 0.0f)
+ }
+ else if (hsv[2] < 0.0f) {
hsv[2] = 0.0f;
+ }
hsv_to_rgb(hsv[0], hsv[1], hsv[2], col, col + 1, col + 2);
out[0] = mfac * in[0] + fac * col[0];
diff --git a/source/blender/nodes/texture/nodes/node_texture_image.c b/source/blender/nodes/texture/nodes/node_texture_image.c
index 5c7b7a56d3a..2ecd66ac6f5 100644
--- a/source/blender/nodes/texture/nodes/node_texture_image.c
+++ b/source/blender/nodes/texture/nodes/node_texture_image.c
@@ -53,24 +53,30 @@ static void colorfn(
px = (int)((x - xoff) * xsize);
py = (int)((y - yoff) * ysize);
- if ((!xsize) || (!ysize))
+ if ((!xsize) || (!ysize)) {
return;
+ }
if (!ibuf->rect_float) {
BLI_thread_lock(LOCK_IMAGE);
- if (!ibuf->rect_float)
+ if (!ibuf->rect_float) {
IMB_float_from_rect(ibuf);
+ }
BLI_thread_unlock(LOCK_IMAGE);
}
- while (px < 0)
+ while (px < 0) {
px += ibuf->x;
- while (py < 0)
+ }
+ while (py < 0) {
py += ibuf->y;
- while (px >= ibuf->x)
+ }
+ while (px >= ibuf->x) {
px -= ibuf->x;
- while (py >= ibuf->y)
+ }
+ while (py >= ibuf->y) {
py -= ibuf->y;
+ }
result = ibuf->rect_float + py * ibuf->x * 4 + px * 4;
copy_v4_v4(out, result);
diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c
index 8b934be3698..2eb32e0addc 100644
--- a/source/blender/nodes/texture/nodes/node_texture_math.c
+++ b/source/blender/nodes/texture/nodes/node_texture_math.c
@@ -53,10 +53,13 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
*out = in0 * in1;
break;
case NODE_MATH_DIVIDE: {
- if (in1 == 0) /* We don't want to divide by zero. */
+ if (in1 == 0) {
+ /* We don't want to divide by zero. */
*out = 0.0;
- else
+ }
+ else {
*out = in0 / in1;
+ }
break;
}
case NODE_MATH_SIN: {
@@ -73,18 +76,22 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
case NODE_MATH_ASIN: {
/* Can't do the impossible... */
- if (in0 <= 1 && in0 >= -1)
+ if (in0 <= 1 && in0 >= -1) {
*out = asinf(in0);
- else
+ }
+ else {
*out = 0.0;
+ }
break;
}
case NODE_MATH_ACOS: {
/* Can't do the impossible... */
- if (in0 <= 1 && in0 >= -1)
+ if (in0 <= 1 && in0 >= -1) {
*out = acosf(in0);
- else
+ }
+ else {
*out = 0.0;
+ }
break;
}
case NODE_MATH_ATAN: {
@@ -109,24 +116,30 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
case NODE_MATH_LOG: {
/* Don't want any imaginary numbers... */
- if (in0 > 0 && in1 > 0)
+ if (in0 > 0 && in1 > 0) {
*out = log(in0) / log(in1);
- else
+ }
+ else {
*out = 0.0;
+ }
break;
}
case NODE_MATH_MIN: {
- if (in0 < in1)
+ if (in0 < in1) {
*out = in0;
- else
+ }
+ else {
*out = in1;
+ }
break;
}
case NODE_MATH_MAX: {
- if (in0 > in1)
+ if (in0 > in1) {
*out = in0;
- else
+ }
+ else {
*out = in1;
+ }
break;
}
case NODE_MATH_ROUND: {
@@ -135,26 +148,32 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
case NODE_MATH_LESS: {
- if (in0 < in1)
+ if (in0 < in1) {
*out = 1.0f;
- else
+ }
+ else {
*out = 0.0f;
+ }
break;
}
case NODE_MATH_GREATER: {
- if (in0 > in1)
+ if (in0 > in1) {
*out = 1.0f;
- else
+ }
+ else {
*out = 0.0f;
+ }
break;
}
case NODE_MATH_MOD: {
- if (in1 == 0.0f)
+ if (in1 == 0.0f) {
*out = 0.0f;
- else
+ }
+ else {
*out = fmod(in0, in1);
+ }
break;
}
@@ -184,10 +203,12 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
case NODE_MATH_SQRT: {
- if (in0 > 0.0f)
+ if (in0 > 0.0f) {
*out = sqrtf(in0);
- else
+ }
+ else {
*out = 0.0f;
+ }
break;
}
diff --git a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
index 667b1317ea4..644dcb5fc67 100644
--- a/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
+++ b/source/blender/nodes/texture/nodes/node_texture_mixRgb.c
@@ -45,8 +45,9 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
tex_input_rgba(col2, in[2], p, thread);
/* use alpha */
- if (node->custom2 & 1)
+ if (node->custom2 & 1) {
fac *= col2[3];
+ }
CLAMP(fac, 0.0f, 1.0f);
diff --git a/source/blender/nodes/texture/nodes/node_texture_output.c b/source/blender/nodes/texture/nodes/node_texture_output.c
index e44bea3ecac..23cd23b4b8d 100644
--- a/source/blender/nodes/texture/nodes/node_texture_output.c
+++ b/source/blender/nodes/texture/nodes/node_texture_output.c
@@ -46,10 +46,12 @@ static void exec(void *data,
TexParams params;
params_from_cdata(&params, cdata);
- if (in[1] && in[1]->hasinput && !in[0]->hasinput)
+ if (in[1] && in[1]->hasinput && !in[0]->hasinput) {
tex_input_rgba(&target->tr, in[1], &params, cdata->thread);
- else
+ }
+ else {
tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
+ }
tex_do_preview(execdata->preview, params.co, &target->tr, cdata->do_manage);
}
else {
@@ -64,10 +66,12 @@ static void exec(void *data,
target->talpha = true;
if (target->nor) {
- if (in[1] && in[1]->hasinput)
+ if (in[1] && in[1]->hasinput) {
tex_input_vec(target->nor, in[1], &params, cdata->thread);
- else
+ }
+ else {
target->nor = NULL;
+ }
}
}
}
@@ -84,8 +88,9 @@ static void unique_name(bNode *node)
new_name[0] = '\0';
i = node;
- while (i->prev)
+ while (i->prev) {
i = i->prev;
+ }
for (; i; i = i->next) {
if (i == node || i->type != TEX_NODE_OUTPUT ||
!STREQ(name, ((TexNodeOutput *)(i->storage))->name)) {
@@ -100,8 +105,9 @@ static void unique_name(bNode *node)
else {
suffix = 0;
new_len = len + 4;
- if (new_len > (sizeof(tno->name) - 1))
+ if (new_len > (sizeof(tno->name) - 1)) {
new_len = (sizeof(tno->name) - 1);
+ }
}
BLI_strncpy(new_name, name, sizeof(tno->name));
@@ -121,8 +127,9 @@ static void assign_index(struct bNode *node)
int index = 1;
tnode = node;
- while (tnode->prev)
+ while (tnode->prev) {
tnode = tnode->prev;
+ }
check_index:
for (; tnode; tnode = tnode->next)
diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c
index 8024ccdc631..bf7cdf18d44 100644
--- a/source/blender/nodes/texture/nodes/node_texture_proc.c
+++ b/source/blender/nodes/texture/nodes/node_texture_proc.c
@@ -59,14 +59,16 @@ static void do_proc(float *result,
if (is_normal) {
texres.nor = result;
}
- else
+ else {
texres.nor = NULL;
+ }
textype = multitex_nodes(
tex, p->co, p->dxt, p->dyt, p->osatex, &texres, thread, 0, p->mtex, NULL);
- if (is_normal)
+ if (is_normal) {
return;
+ }
if (textype & TEX_RGB) {
copy_v4_v4(result, &texres.tr);
@@ -276,8 +278,9 @@ ProcDef(stucci)
BKE_texture_default(tex);
tex->type = node->type - TEX_NODE_PROC;
- if (tex->type == TEX_WOOD)
+ if (tex->type == TEX_WOOD) {
tex->stype = TEX_BANDNOISE;
+ }
}
/* Node type definitions */