diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/nodes/texture/nodes/node_texture_bricks.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/nodes/texture/nodes/node_texture_bricks.c')
-rw-r--r-- | source/blender/nodes/texture/nodes/node_texture_bricks.c | 150 |
1 files changed, 76 insertions, 74 deletions
diff --git a/source/blender/nodes/texture/nodes/node_texture_bricks.c b/source/blender/nodes/texture/nodes/node_texture_bricks.c index 0f034de99ec..c500fa31d34 100644 --- a/source/blender/nodes/texture/nodes/node_texture_bricks.c +++ b/source/blender/nodes/texture/nodes/node_texture_bricks.c @@ -21,107 +21,109 @@ * \ingroup texnodes */ - #include "node_texture_util.h" #include "NOD_texture.h" #include <math.h> static bNodeSocketTemplate inputs[] = { - { SOCK_RGBA, 1, N_("Bricks 1"), 0.596f, 0.282f, 0.0f, 1.0f }, - { SOCK_RGBA, 1, N_("Bricks 2"), 0.632f, 0.504f, 0.05f, 1.0f }, - { SOCK_RGBA, 1, N_("Mortar"), 0.0f, 0.0f, 0.0f, 1.0f }, - { SOCK_FLOAT, 1, N_("Thickness"), 0.02f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Bias"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE }, - { SOCK_FLOAT, 1, N_("Brick Width"), 0.5f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED }, - { SOCK_FLOAT, 1, N_("Row Height"), 0.25f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED }, - { -1, 0, "" }, + {SOCK_RGBA, 1, N_("Bricks 1"), 0.596f, 0.282f, 0.0f, 1.0f}, + {SOCK_RGBA, 1, N_("Bricks 2"), 0.632f, 0.504f, 0.05f, 1.0f}, + {SOCK_RGBA, 1, N_("Mortar"), 0.0f, 0.0f, 0.0f, 1.0f}, + {SOCK_FLOAT, 1, N_("Thickness"), 0.02f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_UNSIGNED}, + {SOCK_FLOAT, 1, N_("Bias"), 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, PROP_NONE}, + {SOCK_FLOAT, 1, N_("Brick Width"), 0.5f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED}, + {SOCK_FLOAT, 1, N_("Row Height"), 0.25f, 0.0f, 0.0f, 0.0f, 0.001f, 99.0f, PROP_UNSIGNED}, + {-1, 0, ""}, }; static bNodeSocketTemplate outputs[] = { - { SOCK_RGBA, 0, N_("Color")}, - { -1, 0, ""}, + {SOCK_RGBA, 0, N_("Color")}, + {-1, 0, ""}, }; static void init(bNodeTree *UNUSED(ntree), bNode *node) { - node->custom3 = 0.5; /* offset */ - node->custom4 = 1.0; /* squash */ + node->custom3 = 0.5; /* offset */ + node->custom4 = 1.0; /* squash */ } static float noise(int n) /* fast integer noise */ { - int nn; - n = (n >> 13) ^ n; - nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; - return 0.5f * ((float)nn / 1073741824.0f); + int nn; + n = (n >> 13) ^ n; + nn = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff; + return 0.5f * ((float)nn / 1073741824.0f); } static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) { - const float *co = p->co; - - float x = co[0]; - float y = co[1]; - - int bricknum, rownum; - float offset = 0; - float ins_x, ins_y; - float tint; - - float bricks1[4]; - float bricks2[4]; - float mortar[4]; - - float mortar_thickness = tex_input_value(in[3], p, thread); - float bias = tex_input_value(in[4], p, thread); - float brick_width = tex_input_value(in[5], p, thread); - float row_height = tex_input_value(in[6], p, thread); - - tex_input_rgba(bricks1, in[0], p, thread); - tex_input_rgba(bricks2, in[1], p, thread); - tex_input_rgba(mortar, in[2], p, thread); - - rownum = (int)floor(y / row_height); - - if (node->custom1 && node->custom2) { - brick_width *= ((int)(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */ - offset = ((int)(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */ - } - - bricknum = (int)floor((x + offset) / brick_width); - - ins_x = (x + offset) - brick_width * bricknum; - ins_y = y - row_height * rownum; - - tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias; - CLAMP(tint, 0.0f, 1.0f); - - if (ins_x < mortar_thickness || ins_y < mortar_thickness || - ins_x > (brick_width - mortar_thickness) || - ins_y > (row_height - mortar_thickness)) - { - copy_v4_v4(out, mortar); - } - else { - copy_v4_v4(out, bricks1); - ramp_blend(MA_RAMP_BLEND, out, tint, bricks2); - } + const float *co = p->co; + + float x = co[0]; + float y = co[1]; + + int bricknum, rownum; + float offset = 0; + float ins_x, ins_y; + float tint; + + float bricks1[4]; + float bricks2[4]; + float mortar[4]; + + float mortar_thickness = tex_input_value(in[3], p, thread); + float bias = tex_input_value(in[4], p, thread); + float brick_width = tex_input_value(in[5], p, thread); + float row_height = tex_input_value(in[6], p, thread); + + tex_input_rgba(bricks1, in[0], p, thread); + tex_input_rgba(bricks2, in[1], p, thread); + tex_input_rgba(mortar, in[2], p, thread); + + rownum = (int)floor(y / row_height); + + if (node->custom1 && node->custom2) { + brick_width *= ((int)(rownum) % node->custom2) ? 1.0f : node->custom4; /* squash */ + offset = ((int)(rownum) % node->custom1) ? 0 : (brick_width * node->custom3); /* offset */ + } + + bricknum = (int)floor((x + offset) / brick_width); + + ins_x = (x + offset) - brick_width * bricknum; + ins_y = y - row_height * rownum; + + tint = noise((rownum << 16) + (bricknum & 0xFFFF)) + bias; + CLAMP(tint, 0.0f, 1.0f); + + if (ins_x < mortar_thickness || ins_y < mortar_thickness || + ins_x > (brick_width - mortar_thickness) || ins_y > (row_height - mortar_thickness)) { + copy_v4_v4(out, mortar); + } + else { + copy_v4_v4(out, bricks1); + ramp_blend(MA_RAMP_BLEND, out, tint, bricks2); + } } -static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out) +static void exec(void *data, + int UNUSED(thread), + bNode *node, + bNodeExecData *execdata, + bNodeStack **in, + bNodeStack **out) { - tex_output(node, execdata, in, out[0], &colorfn, data); + tex_output(node, execdata, in, out[0], &colorfn, data); } void register_node_type_tex_bricks(void) { - static bNodeType ntype; + static bNodeType ntype; - tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN, NODE_PREVIEW); - node_type_socket_templates(&ntype, inputs, outputs); - node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); - node_type_init(&ntype, init); - node_type_exec(&ntype, NULL, NULL, exec); + tex_node_type_base(&ntype, TEX_NODE_BRICKS, "Bricks", NODE_CLASS_PATTERN, NODE_PREVIEW); + node_type_socket_templates(&ntype, inputs, outputs); + node_type_size_preset(&ntype, NODE_SIZE_MIDDLE); + node_type_init(&ntype, init); + node_type_exec(&ntype, NULL, NULL, exec); - nodeRegisterType(&ntype); + nodeRegisterType(&ntype); } |