From: Thomas Köppe Date: Sun, 14 Aug 2016 11:13:18 +0000 (+0100) Subject: [tools/quake3/q3map2/light{,maps}_ydnar.c] Fix float-to-int conversion by preventing... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=12e838fba57e374d02e86a7e8286790b5b9bd1c7;p=xonotic%2Fnetradiant.git [tools/quake3/q3map2/light{,maps}_ydnar.c] Fix float-to-int conversion by preventing NaN values --- diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 91f5e047..5bb8438d 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -2216,7 +2216,7 @@ void IlluminateRawLightmap( int rawLightmapNum ){ } /* set luxel filter radius */ - luxelFilterRadius = superSample * filterRadius / lm->sampleSize; + luxelFilterRadius = lm->sampleSize != 0 ? superSample * filterRadius / lm->sampleSize : 0; if ( luxelFilterRadius == 0 && ( filterRadius > 0.0f || filter ) ) { luxelFilterRadius = 1; } diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index 462331f1..c5633ae3 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -525,7 +525,7 @@ qboolean AddPatchToRawLightmap( int num, rawLightmap_t *lm ){ length = 0; for ( x = 0; x < ( mesh->width - 1 ); x++ ) length += widthTable[ x ]; - lm->w = ceil( length / lm->sampleSize ) + 1; + lm->w = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0; if ( lm->w < ds->patchWidth ) { lm->w = ds->patchWidth; } @@ -538,7 +538,7 @@ qboolean AddPatchToRawLightmap( int num, rawLightmap_t *lm ){ length = 0; for ( y = 0; y < ( mesh->height - 1 ); y++ ) length += heightTable[ y ]; - lm->h = ceil( length / lm->sampleSize ) + 1; + lm->h = lm->sampleSize != 0 ? ceil( length / lm->sampleSize ) + 1 : 0; if ( lm->h < ds->patchHeight ) { lm->h = ds->patchHeight; }