From 1654aa34c50f9cf64223f21031da5520a9420858 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 26 Dec 2018 23:15:28 -0500 Subject: [PATCH] Fix floating point comparisons --- src/hardware/hw_model.c | 4 +++- src/hardware/r_opengl/r_opengl.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_model.c b/src/hardware/hw_model.c index 82833956..394b0f89 100644 --- a/src/hardware/hw_model.c +++ b/src/hardware/hw_model.c @@ -412,7 +412,9 @@ void GenerateVertexNormals(model_t *model) testY = *testPtr++; testZ = *testPtr++; - if (x != testX || y != testY || z != testZ) + if (fabsf(x - testX) > FLT_EPSILON + || fabsf(y - testY) > FLT_EPSILON + || fabsf(z - testZ) > FLT_EPSILON) continue; // Found a vertex match! Add it... diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 4f77680d..22a4d7df 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -964,7 +964,7 @@ EXPORT void HWRAPI(Draw2DLine) (F2DCoord * v1, c.alpha = byte2float[Color.s.alpha]; // This is the preferred, 'modern' way of rendering lines -- creating a polygon. - if (v2->x != v1->x) + if (fabsf(v2->x - v1->x) > FLT_EPSILON) angle = (float)atan((v2->y-v1->y)/(v2->x-v1->x)); else angle = (float)N_PI_DEMI; @@ -1770,7 +1770,7 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 if (nextFrameIndex != -1) nextframe = &mesh->tinyframes[nextFrameIndex % mesh->numFrames]; - if (!nextframe || pol == 0.0f) + if (!nextframe || fpclassify(pol) == FP_ZERO) { pglVertexPointer(3, GL_SHORT, 0, frame->vertices); pglNormalPointer(GL_BYTE, 0, frame->normals); @@ -2151,6 +2151,8 @@ EXPORT void HWRAPI(DoScreenWipe)(float alpha) INT32 fademaskdownloaded = tex_downloaded; // the fade mask that has been set + (void)alpha; + // Use a power of two texture, dammit if(screen_width <= 1024) texsize = 1024;