diff options
author | Ton Roosendaal <ton@blender.org> | 2012-11-05 19:58:35 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2012-11-05 19:58:35 +0400 |
commit | 97a1caea8a57ab71ff1463d45301666c6a46bd0a (patch) | |
tree | 0c8a78dba51205f95c526e0ce5a7ca1ae2e9eb43 /source/blender/nodes | |
parent | 2f9e846e7df684e6d065f47d4bf8845c32abc5a6 (diff) |
Fix for Math node:
A test variable needed to be absoluted (positive).
Gives expected resuts on negative raiser values.
(next; digging in opencl :)
(In old compo code too, not effective).
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/composite/nodes/node_composite_math.c | 3 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_math.c | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/source/blender/nodes/composite/nodes/node_composite_math.c b/source/blender/nodes/composite/nodes/node_composite_math.c index c99e12a95b9..bbd44c58314 100644 --- a/source/blender/nodes/composite/nodes/node_composite_math.c +++ b/source/blender/nodes/composite/nodes/node_composite_math.c @@ -103,7 +103,8 @@ static void do_math(bNode *node, float *out, float *in, float *in2) out[0] = pow(in[0], in2[0]); } else { - float y_mod_1 = fmod(in2[0], 1); + float y_mod_1 = ABS(fmod(in2[0], 1)); + /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { out[0] = powf(in[0], floorf(in2[0] + 0.5f)); diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index f4e0faf2110..9dc900e6bd4 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -142,7 +142,7 @@ bNodeStack **out) out[0]->vec[0] = pow(in[0]->vec[0], in[1]->vec[0]); } else { - float y_mod_1 = fmod(in[1]->vec[0], 1); + float y_mod_1 = ABS(fmod(in[1]->vec[0], 1)); /* if input value is not nearly an integer, fall back to zero, nicer than straight rounding */ if (y_mod_1 > 0.999f || y_mod_1 < 0.001f) { |