From f463907e46f00aff6f267f713d4e8b8c5e741487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20K=C3=B6ppe?= Date: Sun, 14 Aug 2016 12:13:18 +0100 Subject: [PATCH] [tools/quake3/q3map2/light{,maps}_ydnar.c] Fix float-to-int conversion by preventing NaN values --- tools/quake3/q3map2/light_ydnar.c | 2 +- tools/quake3/q3map2/lightmaps_ydnar.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 8d653e3b..e951771c 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -2033,7 +2033,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 2079cbb0..e94f101f 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -518,7 +518,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; } @@ -531,7 +531,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; }