]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/light_ydnar.c
Fix netradiant#182
[xonotic/netradiant.git] / tools / quake3 / q3map2 / light_ydnar.c
index eee4a17362c7ddf71d218aca2de8a4a9be6c73d4..380ed24353e8ca4885abb35831d770d69e2d9fe2 100644 (file)
@@ -829,6 +829,12 @@ static qboolean MapTriangle( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert
                return qfalse;
        }
 
+       /* prevent division by zero */
+       if ( plane[ lm->axisNum ] == 0 ) {
+               Sys_FPrintf( SYS_WRN, "WARNING: plane[lm->axisNum] == 0\n" );
+               return qfalse;
+       }
+
        /* check to see if we need to calculate texture->world tangent vectors */
        if ( info->si->normalImage != NULL && CalcTangentVectors( 3, dv, stvStatic, ttvStatic ) ) {
                stv = stvStatic;
@@ -1000,6 +1006,12 @@ static qboolean MapQuad( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t *
                return qfalse;
        }
 
+       /* prevent division by zero */
+       if ( plane[ lm->axisNum ] == 0 ) {
+               Sys_FPrintf( SYS_WRN, "WARNING: plane[lm->axisNum] == 0\n" );
+               return qfalse;
+       }
+
        /* 4th point must fall on the plane */
        dist = DotProduct( plane, dv[ 3 ]->xyz ) - plane[ 3 ];
        if ( fabs( dist ) > QUAD_PLANAR_EPSILON ) {
@@ -3670,6 +3682,7 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag ){
                                /* clear light envelope */
                                light->envelope = 0;
 
+                               /* FIXME: radius may be undefined */
                                /* handle area lights */
                                if ( exactPointToPolygon && light->type == EMIT_AREA && light->w != NULL ) {
                                        light->envelope = MAX_WORLD_COORD * 8.0f;