]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/light_trace.c
alphashadow/lightfilter: bound the texcoords after converting to integer to guard...
[xonotic/netradiant.git] / tools / quake3 / q3map2 / light_trace.c
index d52f816b5bb5670619d0c6f88e210487f0b5f247..a328f4666bc619b1708178da9ea47189b6ba53b5 100644 (file)
@@ -521,13 +521,10 @@ void ClipTraceWinding( traceWinding_t *tw, vec4_t plane, traceWinding_t *front,
                                        mid.xyz[ k ] = -plane[ 3 ];
                                else
                                        mid.xyz[ k ] = a->xyz[ k ] + frac * (b->xyz[ k ] - a->xyz[ k ]);
-                               
-                               /* set texture coordinates */
-                               if( k > 1 )
-                                       continue;
-                               mid.st[ 0 ] = a->st[ 0 ] + frac * (b->st[ 0 ] - a->st[ 0 ]);
-                               mid.st[ 1 ] = a->st[ 1 ] + frac * (b->st[ 1 ] - a->st[ 1 ]);
                        }
+                       /* set texture coordinates */
+                       mid.st[ 0 ] = a->st[ 0 ] + frac * (b->st[ 0 ] - a->st[ 0 ]);
+                       mid.st[ 1 ] = a->st[ 1 ] + frac * (b->st[ 1 ] - a->st[ 1 ]);
                        
                        /* copy midpoint to front and back polygons */
                        front->v[ front->numVerts++ ] = mid;
@@ -538,39 +535,6 @@ void ClipTraceWinding( traceWinding_t *tw, vec4_t plane, traceWinding_t *front,
 
 
 
-/*
-FilterPointToTraceNodes_r() - ydnar
-debugging tool
-*/
-
-static int FilterPointToTraceNodes_r( vec3_t pt, int nodeNum )
-{
-       float                   dot;
-       traceNode_t             *node;
-       
-       
-       if( nodeNum < 0 || nodeNum >= numTraceNodes )
-               return -1;
-       
-       node = &traceNodes[ nodeNum ];
-       
-       if( node->type >= 0 )
-       {
-               dot = DotProduct( pt, node->plane ) - node->plane[ 3 ];
-               if( dot > -0.001f )
-                       FilterPointToTraceNodes_r( pt, node->children[ 0 ] );
-               if( dot < 0.001f )
-                       FilterPointToTraceNodes_r( pt, node->children[ 1 ] );
-               return -1;
-       }
-       
-       Sys_Printf( "%d ", nodeNum );
-       
-       return nodeNum;
-}
-
-
-
 /*
 FilterTraceWindingIntoNodes_r() - ydnar
 filters a trace winding into the raytracing tree
@@ -1256,8 +1220,12 @@ static void PopulateTraceNodes( void )
                        
                        /* external model */
                        default:
-                               frame = IntForKey( e, "_frame" );
-                               model = LoadModel( (char*) value, frame );
+                               frame = 0;
+                               if(strcmp("", ValueForKey( e, "_frame")))
+                                       frame = IntForKey(e, "_frame");
+                               else if(strcmp("", ValueForKey( e, "frame")))
+                                       frame = IntForKey(e, "frame");
+                               model = LoadModel( value, frame );
                                if( model == NULL )
                                        continue;
                                PopulateWithPicoModel( castShadows, model, transform );
@@ -1285,7 +1253,7 @@ static void PopulateTraceNodes( void )
                        /* external model */
                        default:
                                frame = IntForKey( e, "_frame2" );
-                               model = LoadModel( (char*) value, frame );
+                               model = LoadModel( value, frame );
                                if( model == NULL )
                                        continue;
                                PopulateWithPicoModel( castShadows, model, transform );
@@ -1530,6 +1498,10 @@ qboolean TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace )
        t = t - floor( t );
        is = s * si->lightImage->width;
        it = t * si->lightImage->height;
+       if(is < 0) is = 0;
+       if(is > si->lightImage->width - 1) is = si->lightImage->width - 1;
+       if(it < 0) it = 0;
+       if(it > si->lightImage->height - 1) it = si->lightImage->height - 1;
        
        /* get pixel */
        pixel = si->lightImage->pixels + 4 * (it * si->lightImage->width + is);