diff options
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_math.c | 39 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_socket.c | 5 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_util.c | 96 | ||||
-rw-r--r-- | source/blender/nodes/intern/node_util.h | 5 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_math.c | 39 | ||||
-rw-r--r-- | source/blender/nodes/texture/nodes/node_texture_math.c | 39 |
6 files changed, 108 insertions, 115 deletions
diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c index 741c0e48806..3efb650c6eb 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.c +++ b/source/blender/nodes/composite/nodes/node_composite_math.c @@ -32,43 +32,6 @@ static bNodeSocketTemplate cmp_node_math_in[] = { static bNodeSocketTemplate cmp_node_math_out[] = {{SOCK_FLOAT, 0, N_("Value")}, {-1, 0, ""}}; -static void node_shader_update_math(bNodeTree *UNUSED(ntree), bNode *node) -{ - bNodeSocket *sock = BLI_findlink(&node->inputs, 1); - nodeSetSocketAvailability(sock, - !ELEM(node->custom1, - NODE_MATH_SQRT, - NODE_MATH_SIGN, - NODE_MATH_CEIL, - NODE_MATH_SINE, - NODE_MATH_ROUND, - NODE_MATH_FLOOR, - NODE_MATH_COSINE, - NODE_MATH_ARCSINE, - NODE_MATH_TANGENT, - NODE_MATH_ABSOLUTE, - NODE_MATH_RADIANS, - NODE_MATH_DEGREES, - NODE_MATH_FRACTION, - NODE_MATH_ARCCOSINE, - NODE_MATH_ARCTANGENT) && - !ELEM(node->custom1, - NODE_MATH_INV_SQRT, - NODE_MATH_TRUNC, - NODE_MATH_EXPONENT, - NODE_MATH_COSH, - NODE_MATH_SINH, - NODE_MATH_TANH)); - bNodeSocket *sock2 = BLI_findlink(&node->inputs, 2); - nodeSetSocketAvailability(sock2, - ELEM(node->custom1, - NODE_MATH_COMPARE, - NODE_MATH_MULTIPLY_ADD, - NODE_MATH_WRAP, - NODE_MATH_SMOOTH_MIN, - NODE_MATH_SMOOTH_MAX)); -} - void register_node_type_cmp_math(void) { static bNodeType ntype; @@ -76,7 +39,7 @@ void register_node_type_cmp_math(void) cmp_node_type_base(&ntype, CMP_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, cmp_node_math_in, cmp_node_math_out); node_type_label(&ntype, node_math_label); - node_type_update(&ntype, node_shader_update_math); + node_type_update(&ntype, node_math_update); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/intern/node_socket.c b/source/blender/nodes/intern/node_socket.c index 3485bd41660..13f9039379d 100644 --- a/source/blender/nodes/intern/node_socket.c +++ b/source/blender/nodes/intern/node_socket.c @@ -276,6 +276,11 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from) } node_socket_init_default_value(to); + /* use label instead of name if it has been set */ + if (from->label[0] != '\0') { + BLI_strncpy(to->name, from->label, NODE_MAXSTR); + } + switch (from->typeinfo->type) { case SOCK_FLOAT: { bNodeSocketValueFloat *toval = to->default_value; diff --git a/source/blender/nodes/intern/node_util.c b/source/blender/nodes/intern/node_util.c index b16c814ade9..7d029e7a400 100644 --- a/source/blender/nodes/intern/node_util.c +++ b/source/blender/nodes/intern/node_util.c @@ -77,6 +77,102 @@ void *node_initexec_curves(bNodeExecContext *UNUSED(context), return NULL; /* unused return */ } +/**** Updates ****/ + +void node_sock_label(bNodeSocket *sock, const char *name) +{ + BLI_strncpy(sock->label, name, MAX_NAME); +} + +void node_math_update(bNodeTree *UNUSED(ntree), bNode *node) +{ + bNodeSocket *sock1 = BLI_findlink(&node->inputs, 0); + bNodeSocket *sock2 = BLI_findlink(&node->inputs, 1); + bNodeSocket *sock3 = BLI_findlink(&node->inputs, 2); + nodeSetSocketAvailability(sock2, + !ELEM(node->custom1, + NODE_MATH_SQRT, + NODE_MATH_SIGN, + NODE_MATH_CEIL, + NODE_MATH_SINE, + NODE_MATH_ROUND, + NODE_MATH_FLOOR, + NODE_MATH_COSINE, + NODE_MATH_ARCSINE, + NODE_MATH_TANGENT, + NODE_MATH_ABSOLUTE, + NODE_MATH_RADIANS, + NODE_MATH_DEGREES, + NODE_MATH_FRACTION, + NODE_MATH_ARCCOSINE, + NODE_MATH_ARCTANGENT) && + !ELEM(node->custom1, + NODE_MATH_INV_SQRT, + NODE_MATH_TRUNC, + NODE_MATH_EXPONENT, + NODE_MATH_COSH, + NODE_MATH_SINH, + NODE_MATH_TANH)); + nodeSetSocketAvailability(sock3, + ELEM(node->custom1, + NODE_MATH_COMPARE, + NODE_MATH_MULTIPLY_ADD, + NODE_MATH_WRAP, + NODE_MATH_SMOOTH_MIN, + NODE_MATH_SMOOTH_MAX)); + + if (sock1->label[0] != '\0') { + sock1->label[0] = '\0'; + } + if (sock2->label[0] != '\0') { + sock2->label[0] = '\0'; + } + if (sock3->label[0] != '\0') { + sock3->label[0] = '\0'; + } + + switch (node->custom1) { + case NODE_MATH_WRAP: + node_sock_label(sock2, "Min"); + node_sock_label(sock3, "Max"); + break; + case NODE_MATH_MULTIPLY_ADD: + node_sock_label(sock2, "Multiplier"); + node_sock_label(sock3, "Addend"); + break; + case NODE_MATH_LESS_THAN: + case NODE_MATH_GREATER_THAN: + node_sock_label(sock2, "Threshold"); + break; + case NODE_MATH_PINGPONG: + node_sock_label(sock2, "Scale"); + break; + case NODE_MATH_SNAP: + node_sock_label(sock2, "Increment"); + break; + case NODE_MATH_POWER: + node_sock_label(sock1, "Base"); + node_sock_label(sock2, "Exponent"); + break; + case NODE_MATH_LOGARITHM: + node_sock_label(sock2, "Base"); + break; + case NODE_MATH_DEGREES: + node_sock_label(sock1, "Radians"); + break; + case NODE_MATH_RADIANS: + node_sock_label(sock1, "Degrees"); + break; + case NODE_MATH_COMPARE: + node_sock_label(sock3, "Epsilon"); + break; + case NODE_MATH_SMOOTH_MAX: + case NODE_MATH_SMOOTH_MIN: + node_sock_label(sock3, "Distance"); + break; + } +} + /**** Labels ****/ void node_blend_label(bNodeTree *UNUSED(ntree), bNode *node, char *label, int maxlen) diff --git a/source/blender/nodes/intern/node_util.h b/source/blender/nodes/intern/node_util.h index 49117b38aba..a7f09d24a70 100644 --- a/source/blender/nodes/intern/node_util.h +++ b/source/blender/nodes/intern/node_util.h @@ -66,8 +66,11 @@ extern void *node_initexec_curves(struct bNodeExecContext *context, struct bNode *node, bNodeInstanceKey key); -/**** Labels ****/ +/**** Updates ****/ +void node_sock_label(struct bNodeSocket *sock, const char *name); +void node_math_update(struct bNodeTree *ntree, struct bNode *node); +/**** Labels ****/ void node_blend_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); void node_image_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); void node_math_label(struct bNodeTree *ntree, struct bNode *node, char *label, int maxlen); diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index 5d9da7788ee..c2bb48068ac 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -101,43 +101,6 @@ static int gpu_shader_math(GPUMaterial *mat, } } -static void node_shader_update_math(bNodeTree *UNUSED(ntree), bNode *node) -{ - bNodeSocket *sock = BLI_findlink(&node->inputs, 1); - nodeSetSocketAvailability(sock, - !ELEM(node->custom1, - NODE_MATH_SQRT, - NODE_MATH_SIGN, - NODE_MATH_CEIL, - NODE_MATH_SINE, - NODE_MATH_ROUND, - NODE_MATH_FLOOR, - NODE_MATH_COSINE, - NODE_MATH_ARCSINE, - NODE_MATH_TANGENT, - NODE_MATH_ABSOLUTE, - NODE_MATH_RADIANS, - NODE_MATH_DEGREES, - NODE_MATH_FRACTION, - NODE_MATH_ARCCOSINE, - NODE_MATH_ARCTANGENT) && - !ELEM(node->custom1, - NODE_MATH_INV_SQRT, - NODE_MATH_TRUNC, - NODE_MATH_EXPONENT, - NODE_MATH_COSH, - NODE_MATH_SINH, - NODE_MATH_TANH)); - bNodeSocket *sock2 = BLI_findlink(&node->inputs, 2); - nodeSetSocketAvailability(sock2, - ELEM(node->custom1, - NODE_MATH_COMPARE, - NODE_MATH_MULTIPLY_ADD, - NODE_MATH_WRAP, - NODE_MATH_SMOOTH_MIN, - NODE_MATH_SMOOTH_MAX)); -} - void register_node_type_sh_math(void) { static bNodeType ntype; @@ -146,7 +109,7 @@ void register_node_type_sh_math(void) node_type_socket_templates(&ntype, sh_node_math_in, sh_node_math_out); node_type_label(&ntype, node_math_label); node_type_gpu(&ntype, gpu_shader_math); - node_type_update(&ntype, node_shader_update_math); + node_type_update(&ntype, node_math_update); nodeRegisterType(&ntype); } diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c index 310300df204..8abe638216c 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.c +++ b/source/blender/nodes/texture/nodes/node_texture_math.c @@ -336,43 +336,6 @@ static void exec(void *data, tex_output(node, execdata, in, out[0], &valuefn, data); } -static void node_shader_update_math(bNodeTree *UNUSED(ntree), bNode *node) -{ - bNodeSocket *sock = BLI_findlink(&node->inputs, 1); - nodeSetSocketAvailability(sock, - !ELEM(node->custom1, - NODE_MATH_SQRT, - NODE_MATH_SIGN, - NODE_MATH_CEIL, - NODE_MATH_SINE, - NODE_MATH_ROUND, - NODE_MATH_FLOOR, - NODE_MATH_COSINE, - NODE_MATH_ARCSINE, - NODE_MATH_TANGENT, - NODE_MATH_ABSOLUTE, - NODE_MATH_RADIANS, - NODE_MATH_DEGREES, - NODE_MATH_FRACTION, - NODE_MATH_ARCCOSINE, - NODE_MATH_ARCTANGENT) && - !ELEM(node->custom1, - NODE_MATH_INV_SQRT, - NODE_MATH_TRUNC, - NODE_MATH_EXPONENT, - NODE_MATH_COSH, - NODE_MATH_SINH, - NODE_MATH_TANH)); - bNodeSocket *sock2 = BLI_findlink(&node->inputs, 2); - nodeSetSocketAvailability(sock2, - ELEM(node->custom1, - NODE_MATH_COMPARE, - NODE_MATH_MULTIPLY_ADD, - NODE_MATH_WRAP, - NODE_MATH_SMOOTH_MIN, - NODE_MATH_SMOOTH_MAX)); -} - void register_node_type_tex_math(void) { static bNodeType ntype; @@ -382,7 +345,7 @@ void register_node_type_tex_math(void) node_type_label(&ntype, node_math_label); node_type_storage(&ntype, "", NULL, NULL); node_type_exec(&ntype, NULL, NULL, exec); - node_type_update(&ntype, node_shader_update_math); + node_type_update(&ntype, node_math_update); nodeRegisterType(&ntype); } |