diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 06:31:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-22 12:48:17 +0300 |
commit | b102472551c351d8be8ebf96e3e44a5454f02d0a (patch) | |
tree | 1ccd80b94db736cd45f2c038c22e1c7b43642ded /source/blender/nodes/texture | |
parent | 735515a3f9e4c41738bf714d682b13db64adb638 (diff) |
Cleanup: style, use braces for nodes
Diffstat (limited to 'source/blender/nodes/texture')
11 files changed, 129 insertions, 64 deletions
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(¶ms, 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], ¶ms, cdata->thread); - else + } + else { tex_input_rgba(&target->tr, in[0], ¶ms, 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], ¶ms, 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 */ |