#define GROW_TRACE_NODES 16384 //% 16384
#define GROW_NODE_ITEMS 16 //% 256
-#define MAX_TW_VERTS 12
+#define MAX_TW_VERTS 24 // vortex: increased from 12 to 24 for ability co compile some insane maps with large curve count
#define TRACE_ON_EPSILON 0.1f
typedef struct traceInfo_s
{
shaderInfo_t *si;
- int surfaceNum, castShadows;
+ int surfaceNum, castShadows, skipGrid;
}
traceInfo_t;
{
if( traceInfos[ num ].si == ti->si &&
traceInfos[ num ].surfaceNum == ti->surfaceNum &&
- traceInfos[ num ].castShadows == ti->castShadows )
+ traceInfos[ num ].castShadows == ti->castShadows &&
+ traceInfos[ num ].skipGrid == ti->skipGrid )
return num;
}
memset( &traceNodes[ numTraceNodes ], 0, sizeof( traceNode_t ) );
traceNodes[ numTraceNodes ].type = TRACE_LEAF;
ClearBounds( traceNodes[ numTraceNodes ].mins, traceNodes[ numTraceNodes ].maxs );
+
+ /* Sys_Printf("alloc node %d\n", numTraceNodes); */
+
numTraceNodes++;
/* return the count */
static int SetupTraceNodes_r( int bspNodeNum )
{
- int i, nodeNum, bspLeafNum;
+ int i, nodeNum, bspLeafNum, newNode;
bspPlane_t *plane;
bspNode_t *bspNode;
bspLeafNum = -bspNode->children[ i ] - 1;
/* new code */
- traceNodes[ nodeNum ].children[ i ] = AllocTraceNode();
+ newNode = AllocTraceNode();
+ traceNodes[ nodeNum ].children[ i ] = newNode;
+ /* have to do this separately, as gcc first executes LHS, then RHS, and if a realloc took place, this fails */
+
if( bspLeafs[ bspLeafNum ].cluster == -1 )
traceNodes[ traceNodes[ nodeNum ].children[ i ] ].type = TRACE_LEAF_SOLID;
}
/* normal node */
else
- traceNodes[ nodeNum ].children[ i ] = SetupTraceNodes_r( bspNode->children[ i ] );
+ {
+ newNode = SetupTraceNodes_r( bspNode->children[ i ] );
+ traceNodes[ nodeNum ].children[ i ] = newNode;
+ }
+
+ if(traceNodes[ nodeNum ].children[ i ] == 0)
+ Error( "Invalid tracenode allocated" );
}
+
+ /* Sys_Printf("node %d children: %d %d\n", nodeNum, traceNodes[ nodeNum ].children[0], traceNodes[ nodeNum ].children[1]); */
/* return node number */
return nodeNum;
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;
-/*
-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
ti.si = info->si;
ti.castShadows = info->castShadows;
ti.surfaceNum = model->firstBSPBrush + i;
+ ti.skipGrid = (ds->surfaceType == MST_PATCH);
/* choose which node (normal or skybox) */
if( info->parentSurfaceNum >= 0 )
/* setup trace info */
ti.castShadows = castShadows;
ti.surfaceNum = -1;
+ ti.skipGrid = qtrue; // also ignore picomodels when skipping patches
/* setup trace winding */
memset( &tw, 0, sizeof( tw ) );
/* 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 );
/* external model */
default:
frame = IntForKey( e, "_frame2" );
- model = LoadModel( (char*) value, frame );
+ model = LoadModel( value, frame );
if( model == NULL )
continue;
PopulateWithPicoModel( castShadows, model, transform );
if( ti->castShadows != 1 )
return qfalse;
}
-
+
/* receive shadows from same group and worldspawn group */
else if( trace->recvShadows > 1 )
{
return qfalse;
}
+ /* skip patches when doing the grid (FIXME this is an ugly hack) */
+ if( inGrid )
+ {
+ if (ti->skipGrid)
+ return qfalse;
+ }
+
/* begin calculating determinant - also used to calculate u parameter */
CrossProduct( trace->direction, tt->edge2, pvec );
trace->opaque = qtrue;
return qtrue;
}
+
+ /* force subsampling because the lighting is texture dependent */
+ trace->forceSubsampling = 1.0;
/* try to avoid double shadows near triangle seams */
if( u < -ASLF_EPSILON || u > (1.0f + ASLF_EPSILON) ||
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);
/* check filter for opaque */
if( trace->color[ 0 ] <= 0.001f && trace->color[ 1 ] <= 0.001f && trace->color[ 2 ] <= 0.001f )
{
+ VectorClear( trace->color );
VectorMA( trace->origin, depth, trace->direction, trace->hit );
trace->opaque = qtrue;
return qtrue;