From 8a312979ef02fbcd382329d9287021acebf213f3 Mon Sep 17 00:00:00 2001 From: Lukas Toenne Date: Sun, 6 Mar 2011 13:11:57 +0000 Subject: Applied patch by Alexander Kuznetsov for bug 26373: math node 'round' mode was not working correctly for negative numbers. --- source/blender/nodes/intern/CMP_nodes/CMP_math.c | 2 +- source/blender/nodes/intern/SHD_nodes/SHD_math.c | 4 ++-- source/blender/nodes/intern/TEX_nodes/TEX_math.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'source/blender/nodes/intern') diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_math.c b/source/blender/nodes/intern/CMP_nodes/CMP_math.c index 09c08f01a8a..039f7e6fab1 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_math.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_math.c @@ -140,7 +140,7 @@ static void do_math(bNode *node, float *out, float *in, float *in2) break; case 14: /* Round */ { - out[0]= (int)(in[0] + 0.5f); + out[0]= (out[0]<0)?(int)(in[0] - 0.5f):(int)(in[0] + 0.5f); } break; case 15: /* Less Than */ diff --git a/source/blender/nodes/intern/SHD_nodes/SHD_math.c b/source/blender/nodes/intern/SHD_nodes/SHD_math.c index 0c9e9bd0fe3..dd0a564dc4b 100644 --- a/source/blender/nodes/intern/SHD_nodes/SHD_math.c +++ b/source/blender/nodes/intern/SHD_nodes/SHD_math.c @@ -174,9 +174,9 @@ bNodeStack **out) case 14: /* Round */ { if(in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ - out[0]->vec[0]= (int)(in[0]->vec[0] + 0.5f); + out[0]->vec[0]= (in[0]->vec[0]<0)?(int)(in[0]->vec[0] - 0.5f):(int)(in[0]->vec[0] + 0.5f); else - out[0]->vec[0]= (int)(in[1]->vec[0] + 0.5f); + out[0]->vec[0]= (in[1]->vec[0]<0)?(int)(in[1]->vec[0] - 0.5f):(int)(in[1]->vec[0] + 0.5f); } break; case 15: /* Less Than */ diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_math.c b/source/blender/nodes/intern/TEX_nodes/TEX_math.c index add8c24341e..a84573f1d09 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_math.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_math.c @@ -151,7 +151,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor break; case 14: /* Round */ { - *out= (int)(in0 + 0.5f); + *out= (in0<0)?(int)(in0 - 0.5f):(int)(in0 + 0.5f); } break; -- cgit v1.2.3