Applied patch by Alexander Kuznetsov for bug 26373: math node 'round' mode was not working correctly for negative numbers.

This commit is contained in:
Lukas Toenne
2011-03-06 13:11:57 +00:00
parent a803fb095c
commit 8a312979ef
3 changed files with 4 additions and 4 deletions

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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;