Fix floating point comparisons

This commit is contained in:
mazmazz 2018-12-26 23:15:28 -05:00
parent 1249f37fc5
commit 1654aa34c5
2 changed files with 7 additions and 3 deletions

View file

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

View file

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