diff options
author | Matt Heimlich <matt.heimlich@gmail.com> | 2014-05-07 18:20:17 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-05-07 18:43:59 +0400 |
commit | 3fbc984b069fed441cccdd3416ec71e064235e36 (patch) | |
tree | 1c95f9d57457069eb3918deb727fc62b4c83dee5 /source/blender/nodes | |
parent | 8b8d5a441f5815e83f83bacf8023e2cc3fbb2a04 (diff) |
Nodes: add absolute value operation to all math nodes
Reviewed By: dingto, brecht
Differential Revision: https://developer.blender.org/D507
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_math.c | 7 | ||||
-rw-r--r-- | source/blender/nodes/texture/nodes/node_texture_math.c | 9 |
2 files changed, 14 insertions, 2 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index b6c755571c0..ed88e800d33 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -216,6 +216,11 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode r = fmod(a, b); break; } + case 18: /* Absolute */ + { + r = fabs(a); + break; + } } out[0]->vec[0] = r; @@ -226,7 +231,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED( static const char *names[] = {"math_add", "math_subtract", "math_multiply", "math_divide", "math_sine", "math_cosine", "math_tangent", "math_asin", "math_acos", "math_atan", "math_pow", "math_log", "math_min", "math_max", - "math_round", "math_less_than", "math_greater_than", "math_modulo"}; + "math_round", "math_less_than", "math_greater_than", "math_modulo", "math_absolute"}; switch (node->custom1) { case 0: diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c index 8d69d79d847..86d693f7dfa 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.c +++ b/source/blender/nodes/texture/nodes/node_texture_math.c @@ -174,7 +174,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor break; } - case 17: /* Modulo */ + case 17: /* Modulo */ { if (in1 == 0.0f) *out = 0.0f; @@ -182,6 +182,13 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor *out = fmod(in0, in1); break; } + + case 18: /* Absolute */ + { + *out = fabs(in0); + break; + } + default: { BLI_assert(0); |