lightgrid search fix; increase max vertices of poly
authordivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Sun, 4 Oct 2009 15:17:11 +0000 (15:17 +0000)
committerdivverent <divverent@61c419a2-8eb2-4b30-bcec-8cead039b335>
Sun, 4 Oct 2009 15:17:11 +0000 (15:17 +0000)
git-svn-id: svn://svn.icculus.org/netradiant/trunk@398 61c419a2-8eb2-4b30-bcec-8cead039b335

tools/quake3/common/polylib.h
tools/quake3/q3map2/light.c

index e58875a2266594d1ce96bad062d069dc0d9cc5bb..d78c780d68781d2848111be2a02d58627cea98b4 100644 (file)
@@ -26,7 +26,7 @@ typedef struct
        vec3_t  p[4];           // variable sized
 } winding_t;
 
-#define        MAX_POINTS_ON_WINDING   64
+#define        MAX_POINTS_ON_WINDING   512
 
 // you can define on_epsilon in the makefile as tighter
 #ifndef        ON_EPSILON
index 9f06cfd361e6955e61057dca3b81a58d1b6f7175..6d3b4c687c773cc09b74e9ebaf5bcd858f603630 100644 (file)
@@ -1274,7 +1274,7 @@ void TraceGrid( int num )
 {
        int                                             i, j, x, y, z, mod, step, numCon, numStyles;
        float                                   d;
-       vec3_t                                  baseOrigin, cheapColor, color;
+       vec3_t                                  baseOrigin, cheapColor, color, thisdir;
        rawGridPoint_t                  *gp;
        bspGridPoint_t                  *bgp;
        contribution_t                  contributions[ MAX_CONTRIBUTIONS ];
@@ -1311,25 +1311,25 @@ void TraceGrid( int num )
        {
                /* try to nudge the origin around to find a valid point */
                VectorCopy( trace.origin, baseOrigin );
-               for( step = 9; step <= 18; step += 9 )
+               for( step = 0.05; step <= 0.5; step += 0.05 )
                {
                        for( i = 0; i < 8; i++ )
                        {
                                VectorCopy( baseOrigin, trace.origin );
                                if( i & 1 )
-                                       trace.origin[ 0 ] += step;
+                                       trace.origin[ 0 ] += step * gridSize[0];
                                else
-                                       trace.origin[ 0 ] -= step;
+                                       trace.origin[ 0 ] -= step * gridSize[0];
                                
                                if( i & 2 )
-                                       trace.origin[ 1 ] += step;
+                                       trace.origin[ 1 ] += step * gridSize[1];
                                else
-                                       trace.origin[ 1 ] -= step;
+                                       trace.origin[ 1 ] -= step * gridSize[1];
                                
                                if( i & 4 )
-                                       trace.origin[ 2 ] += step;
+                                       trace.origin[ 2 ] += step * gridSize[2];
                                else
-                                       trace.origin[ 2 ] -= step;
+                                       trace.origin[ 2 ] -= step * gridSize[2];
                                
                                /* ydnar: changed to find cluster num */
                                trace.cluster = ClusterForPointExt( trace.origin, VERTEX_EPSILON );
@@ -1342,7 +1342,7 @@ void TraceGrid( int num )
                }
                
                /* can't find a valid point at all */
-               if( step > 18 )
+               if( step > 0.5 )
                        return;
        }
        
@@ -1445,7 +1445,7 @@ void TraceGrid( int num )
        /////////////////////
 
        /* normalize to get primary light direction */
-       VectorNormalize( gp->dir, gp->dir );
+       VectorNormalize( gp->dir, thisdir );
        
        /* now that we have identified the primary light direction,
           go back and separate all the light into directed and ambient */
@@ -1454,7 +1454,7 @@ void TraceGrid( int num )
        for( i = 0; i < numCon; i++ )
        {
                /* get relative directed strength */
-               d = DotProduct( contributions[ i ].dir, gp->dir );
+               d = DotProduct( contributions[ i ].dir, thisdir );
                /* we map 1 to gridDirectionality, and 0 to gridAmbientDirectionality */
                d = gridAmbientDirectionality + d * (gridDirectionality - gridAmbientDirectionality);
                if( d < 0.0f )
@@ -1540,8 +1540,7 @@ void TraceGrid( int num )
        #endif
        
        /* store direction */
-       if( !bouncing )
-               NormalToLatLong( gp->dir, bgp->latLong );
+       NormalToLatLong( thisdir, bgp->latLong );
 }
 
 
@@ -2003,7 +2002,7 @@ int LightMain( int argc, char **argv )
                else if( !strcmp( argv[ i ], "-gridambientdirectionality" ) )
                {
                        f = atof( argv[ i + 1 ] );
-                       if(f > gridDirectionality) f = gridDirectionality
+                       if(f > gridDirectionality) f = gridDirectionality;
                        if(f > 1) f = 1;
                        Sys_Printf( "Grid ambient directionality is %f\n", f );
                        gridAmbientDirectionality *= f;