summaryrefslogtreecommitdiffstats
path: root/src/mesa/swrast
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2001-04-10 15:46:51 +0000
committerBrian Paul <[email protected]>2001-04-10 15:46:51 +0000
commit6ac852d45b3a53dc51414773454e6bae7126fe33 (patch)
treef378e494d3cbfa2aa61a7a2213c9e95fb073979c /src/mesa/swrast
parent33143303feaf84afbef2e63ac0adab2d70b3c344 (diff)
fixed some divide by zero conformance problems
Diffstat (limited to 'src/mesa/swrast')
-rw-r--r--src/mesa/swrast/s_aaline.c27
-rw-r--r--src/mesa/swrast/s_aatriangle.c11
2 files changed, 26 insertions, 12 deletions
diff --git a/src/mesa/swrast/s_aaline.c b/src/mesa/swrast/s_aaline.c
index 89df853233c..f60233c3aca 100644
--- a/src/mesa/swrast/s_aaline.c
+++ b/src/mesa/swrast/s_aaline.c
@@ -1,4 +1,4 @@
-/* $Id: s_aaline.c,v 1.7 2001/03/28 21:37:24 brianp Exp $ */
+/* $Id: s_aaline.c,v 1.8 2001/04/10 15:46:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -120,10 +120,18 @@ compute_plane(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
const GLfloat b = pz * py;
const GLfloat c = px * px + py * py;
const GLfloat d = -(a * x0 + b * y0 + c * z0);
- plane[0] = a;
- plane[1] = b;
- plane[2] = c;
- plane[3] = d;
+ if (a == 0.0 && b == 0.0 && c == 0.0 && d == 0.0) {
+ plane[0] = 0.0;
+ plane[1] = 0.0;
+ plane[2] = 1.0;
+ plane[3] = 0.0;
+ }
+ else {
+ plane[0] = a;
+ plane[1] = b;
+ plane[2] = c;
+ plane[3] = d;
+ }
#endif
}
@@ -141,7 +149,7 @@ constant_plane(GLfloat value, GLfloat plane[4])
static INLINE GLfloat
solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4])
{
- GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
+ const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
return z;
}
@@ -155,8 +163,11 @@ solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4])
static INLINE GLfloat
solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4])
{
- GLfloat z = -plane[2] / (plane[3] + plane[0] * x + plane[1] * y);
- return z;
+ const GLfloat denom = plane[3] + plane[0] * x + plane[1] * y;
+ if (denom == 0.0)
+ return 0.0;
+ else
+ return -plane[2] / denom;
}
diff --git a/src/mesa/swrast/s_aatriangle.c b/src/mesa/swrast/s_aatriangle.c
index 93f65b826cc..8235e957e33 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.12 2001/03/29 16:50:32 brianp Exp $ */
+/* $Id: s_aatriangle.c,v 1.13 2001/04/10 15:46:51 brianp Exp $ */
/*
* Mesa 3-D graphics library
@@ -92,7 +92,7 @@ do { \
static INLINE GLfloat
solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4])
{
- GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
+ const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
return z;
}
@@ -107,8 +107,11 @@ solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4])
static INLINE GLfloat
solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4])
{
- GLfloat z = -plane[2] / (plane[3] + plane[0] * x + plane[1] * y);
- return z;
+ const GLfloat denom = plane[3] + plane[0] * x + plane[1] * y;
+ if (denom == 0.0F)
+ return 0.0F;
+ else
+ return -plane[2] / denom;
}