diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2003-01-22 15:03:09 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2003-01-22 15:03:09 +0000 |
commit | a2473160d45f5f33f720a8af31444db227843abb (patch) | |
tree | ac9c020b9552100c84dd13004ea8c29ded89838f /src | |
parent | 7ab14f00f02540520d6d36dd576b5e88db909923 (diff) | |
download | external_mesa3d-a2473160d45f5f33f720a8af31444db227843abb.zip external_mesa3d-a2473160d45f5f33f720a8af31444db227843abb.tar.gz external_mesa3d-a2473160d45f5f33f720a8af31444db227843abb.tar.bz2 |
improved solve_plane_chan() (Evgeny Kotsuba)
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/swrast/s_aatriangle.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c index 95cab18..d3d44d4 100644 --- a/src/mesa/swrast/s_aatriangle.c +++ b/src/mesa/swrast/s_aatriangle.c @@ -1,4 +1,4 @@ -/* $Id: s_aatriangle.c,v 1.27 2003/01/20 15:20:27 brianp Exp $ */ +/* $Id: s_aatriangle.c,v 1.28 2003/01/22 15:03:09 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -132,12 +132,16 @@ solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4]) static INLINE GLchan solve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4]) { - GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2] + 0.5F; - if (z < 0.0F) + const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; +#if CHAN_TYPE == GL_FLOAT + return CLAMP(z, 0.0F, CHAN_MAXF); +#else + if (z < 0) return 0; - else if (z > CHAN_MAXF) - return (GLchan) CHAN_MAXF; - return (GLchan) (GLint) z; + else if (z > CHAN_MAX) + return CHAN_MAX; + return (GLchan) IROUND_POS(z); +#endif } |