[tools/quake3/q3map2/light{,maps}_ydnar.c] Fix float-to-int conversion by preventing...
authorThomas Köppe <tkoeppe@google.com>
Sun, 14 Aug 2016 11:13:18 +0000 (12:13 +0100)
committerThomas Debesse <dev@illwieckz.net>
Fri, 14 Oct 2016 00:38:11 +0000 (02:38 +0200)
tools/quake3/q3map2/light_ydnar.c
tools/quake3/q3map2/lightmaps_ydnar.c

index 91f5e04..5bb8438 100644 (file)
@@ -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;
                        }
index 462331f..c5633ae 100644 (file)
@@ -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;
        }