diff options
author | Ton Roosendaal <ton@blender.org> | 2005-03-24 01:19:51 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-03-24 01:19:51 +0300 |
commit | 8b69f0cfd914762c30586e042510109e4f1c2712 (patch) | |
tree | 7ab0b269ec96c58c4d5ef3e1dc4c6d05befae025 | |
parent | 90caa93d6746b9d7e8dfae52f591181be0a5b072 (diff) |
Bug fix #2337
SHIFT+Z shaded view could display Shadeless overflows, due to lack of
clipping float to a char. :)
-rw-r--r-- | source/blender/blenkernel/intern/displist.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c index 23a9718b2e1..3173c755335 100644 --- a/source/blender/blenkernel/intern/displist.c +++ b/source/blender/blenkernel/intern/displist.c @@ -573,14 +573,22 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co if(ma->mode & MA_SHLESS) { if(vertcol && (ma->mode & (MA_VERTEXCOL+MA_VERTEXCOLP))== MA_VERTEXCOL ) { - col1[3]= vertcol[3]*shi.r; - col1[2]= vertcol[2]*shi.g; - col1[1]= vertcol[1]*shi.b; + float fac; + fac= vertcol[3]*shi.r; + col1[3]= fac>=1.0?255:(char)fac; + fac= vertcol[2]*shi.g; + col1[2]= fac>=1.0?255:(char)fac; + fac= vertcol[2]*shi.b; + col1[1]= fac>=1.0?255:(char)fac; } else { - col1[3]= (255.0*shi.r); - col1[2]= (255.0*shi.g); - col1[1]= (255.0*shi.b); + int fac; + fac= (int) (255.0*shi.r); + col1[3]= fac>255?255:(char)fac; + fac= (int) (255.0*shi.g); + col1[2]= fac>255?255:(char)fac; + fac= (int) (255.0*shi.b); + col1[1]= fac>255?255:(char)fac; } if(col2) { col2[3]= col1[3]; |