diff options
author | Ton Roosendaal <ton@blender.org> | 2011-02-18 15:34:31 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2011-02-18 15:34:31 +0300 |
commit | 538ad31bfbf80dadb2c70dade8d83b9e4aad18a6 (patch) | |
tree | ad17973d7d9ee83ea1527872d0ba1f0b51318832 /source/blender/nodes | |
parent | b74601078d08a923241d3b52e065afd663e2ff3f (diff) |
Bugfix #26128
Compositor/texture nodes: math node now allows to use pow() for
negative raising too, but only when that value is near-integer.
For other negative cases result is zero.
Patch provided by Aurel W
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/intern/CMP_nodes/CMP_math.c | 15 | ||||
-rw-r--r-- | source/blender/nodes/intern/TEX_nodes/TEX_math.c | 16 |
2 files changed, 22 insertions, 9 deletions
diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_math.c b/source/blender/nodes/intern/CMP_nodes/CMP_math.c index 7a8dadafb86..adeef050ec0 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_math.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_math.c @@ -94,11 +94,18 @@ static void do_math(bNode *node, float *out, float *in, float *in2) break; case 10: /* Power */ { - /* Don't want any imaginary numbers... */ - if( in[0] >= 0 ) + /* Only raise negative numbers by full integers */ + if( in[0] >= 0 ) { out[0]= pow(in[0], in2[0]); - else - out[0]= 0.0; + } else { + float y_mod_1 = 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.999 || y_mod_1 < 0.001) { + out[0]= pow(in[0], round(in2[0])); + } else { + out[0] = 0.0; + } + } } break; case 11: /* Logarithm */ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c index 7e1c54b6e47..3043cd756d0 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c @@ -106,11 +106,17 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor break; case 10: /* Power */ { - /* Don't want any imaginary numbers... */ - if( in0 >= 0 ) - *out= pow(in0, in1); - else - *out= 0.0; + /* Only raise negative numbers by full integers */ + if( in0 >= 0 ) { + out[0]= pow(in0, in1); + } else { + float y_mod_1 = fmod(in1, 1); + if (y_mod_1 > 0.999 || y_mod_1 < 0.001) { + *out = pow(in0, round(in1)); + } else { + *out = 0.0; + } + } } break; case 11: /* Logarithm */ |