Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

tr_bsp.c File Reference

#include "tr_local.h"

Include dependency graph for tr_bsp.c:

Include dependency graph

Go to the source code of this file.

Defines

#define LIGHTMAP_SIZE   128

Functions

void HSVtoRGB (float h, float s, float v, float rgb[3])
void ParseFace (dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int *indexes)
void ParseFlare (dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int *indexes)
void ParseMesh (dsurface_t *ds, drawVert_t *verts, msurface_t *surf)
void ParseTriSurf (dsurface_t *ds, drawVert_t *verts, msurface_t *surf, int *indexes)
void R_ColorShiftLightingBytes (byte in[4], byte out[4])
void R_FixSharedVertexLodError (void)
void R_FixSharedVertexLodError_r (int start, srfGridMesh_t *grid1)
qboolean R_GetEntityToken (char *buffer, int size)
void R_LoadEntities (lump_t *l)
void R_LoadFogs (lump_t *l, lump_t *brushesLump, lump_t *sidesLump)
void R_LoadLightGrid (lump_t *l)
void R_LoadLightmaps (lump_t *l)
void R_LoadMarksurfaces (lump_t *l)
void R_LoadNodesAndLeafs (lump_t *nodeLump, lump_t *leafLump)
void R_LoadPlanes (lump_t *l)
void R_LoadShaders (lump_t *l)
void R_LoadSubmodels (lump_t *l)
void R_LoadSurfaces (lump_t *surfs, lump_t *verts, lump_t *indexLump)
void R_LoadVisibility (lump_t *l)
int R_MergedHeightPoints (srfGridMesh_t *grid, int offset)
int R_MergedWidthPoints (srfGridMesh_t *grid, int offset)
void R_MovePatchSurfacesToHunk (void)
void R_SetParent (mnode_t *node, mnode_t *parent)
void R_StitchAllPatches (void)
int R_StitchPatches (int grid1num, int grid2num)
int R_TryStitchingPatch (int grid1num)
void RE_LoadWorldMap (const char *name)
void RE_SetWorldVisData (const byte *vis)
shader_tShaderForShaderNum (int shaderNum, int lightmapNum)

Variables

int c_gridVerts
int c_subdivisions
bytefileBase
world_t s_worldData


Define Documentation

#define LIGHTMAP_SIZE   128
 

Definition at line 134 of file tr_bsp.c.

Referenced by R_LoadLightmaps(), VL_FacetsForPatch(), VL_FixLightmapEdges(), VL_LightmapMatrixFromPoints(), VL_LightSurfaceWithVolume(), VL_SmoothenLightmapEdges(), VS_FacetsForPatch(), VS_FixLightmapEdges(), VS_LightmapMatrixFromPoints(), VS_LightSurfaceWithVolume(), and VS_SmoothenLightmapEdges().


Function Documentation

void HSVtoRGB float  h,
float  s,
float  v,
float  rgb[3]
[static]
 

Definition at line 44 of file tr_bsp.c.

References f, floor(), h(), i, p, q, s, t, and v.

Referenced by R_LoadLightmaps().

00045 {
00046     int i;
00047     float f;
00048     float p, q, t;
00049 
00050     h *= 5;
00051 
00052     i = floor( h );
00053     f = h - i;
00054 
00055     p = v * ( 1 - s );
00056     q = v * ( 1 - s * f );
00057     t = v * ( 1 - s * ( 1 - f ) );
00058 
00059     switch ( i )
00060     {
00061     case 0:
00062         rgb[0] = v;
00063         rgb[1] = t;
00064         rgb[2] = p;
00065         break;
00066     case 1:
00067         rgb[0] = q;
00068         rgb[1] = v;
00069         rgb[2] = p;
00070         break;
00071     case 2:
00072         rgb[0] = p;
00073         rgb[1] = v;
00074         rgb[2] = t;
00075         break;
00076     case 3:
00077         rgb[0] = p;
00078         rgb[1] = q;
00079         rgb[2] = v;
00080         break;
00081     case 4:
00082         rgb[0] = t;
00083         rgb[1] = p;
00084         rgb[2] = v;
00085         break;
00086     case 5:
00087         rgb[0] = v;
00088         rgb[1] = p;
00089         rgb[2] = q;
00090         break;
00091     }
00092 }

Here is the call graph for this function:

void ParseFace dsurface_t ds,
drawVert_t verts,
msurface_t surf,
int *  indexes
[static]
 

Definition at line 303 of file tr_bsp.c.

References byte, msurface_s::data, trGlobals_t::defaultShader, cplane_s::dist, DotProduct, dsurface_t::firstIndex, dsurface_t::firstVert, msurface_s::fogIndex, dsurface_t::fogNum, h_low, refimport_t::Hunk_Alloc, i, cvar_s::integer, shader_s::isSky, j, dsurface_t::lightmapNum, dsurface_t::lightmapVecs, LittleFloat(), LittleLong(), msurface_t, cplane_s::normal, dsurface_t::numIndexes, srfSurfaceFace_t::numIndices, srfSurfaceFace_t::numPoints, dsurface_t::numVerts, srfSurfaceFace_t::ofsIndices, srfSurfaceFace_t::plane, PlaneTypeForNormal, srfSurfaceFace_t::points, PRINT_WARNING, R_ColorShiftLightingBytes(), r_singleShader, ri, SetPlaneSignbits(), msurface_s::shader, ShaderForShaderNum(), dsurface_t::shaderNum, srfSurfaceFace_t::surfaceType, surfaceType_t, tr, and cplane_s::type.

Referenced by R_LoadSurfaces().

00303                                                                                             {
00304     int         i, j;
00305     srfSurfaceFace_t    *cv;
00306     int         numPoints, numIndexes;
00307     int         lightmapNum;
00308     int         sfaceSize, ofsIndexes;
00309 
00310     lightmapNum = LittleLong( ds->lightmapNum );
00311 
00312     // get fog volume
00313     surf->fogIndex = LittleLong( ds->fogNum ) + 1;
00314 
00315     // get shader value
00316     surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapNum );
00317     if ( r_singleShader->integer && !surf->shader->isSky ) {
00318         surf->shader = tr.defaultShader;
00319     }
00320 
00321     numPoints = LittleLong( ds->numVerts );
00322     if (numPoints > MAX_FACE_POINTS) {
00323         ri.Printf( PRINT_WARNING, "WARNING: MAX_FACE_POINTS exceeded: %i\n", numPoints);
00324     numPoints = MAX_FACE_POINTS;
00325     surf->shader = tr.defaultShader;
00326     }
00327 
00328     numIndexes = LittleLong( ds->numIndexes );
00329 
00330     // create the srfSurfaceFace_t
00331     sfaceSize = ( int ) &((srfSurfaceFace_t *)0)->points[numPoints];
00332     ofsIndexes = sfaceSize;
00333     sfaceSize += sizeof( int ) * numIndexes;
00334 
00335     cv = ri.Hunk_Alloc( sfaceSize, h_low );
00336     cv->surfaceType = SF_FACE;
00337     cv->numPoints = numPoints;
00338     cv->numIndices = numIndexes;
00339     cv->ofsIndices = ofsIndexes;
00340 
00341     verts += LittleLong( ds->firstVert );
00342     for ( i = 0 ; i < numPoints ; i++ ) {
00343         for ( j = 0 ; j < 3 ; j++ ) {
00344             cv->points[i][j] = LittleFloat( verts[i].xyz[j] );
00345         }
00346         for ( j = 0 ; j < 2 ; j++ ) {
00347             cv->points[i][3+j] = LittleFloat( verts[i].st[j] );
00348             cv->points[i][5+j] = LittleFloat( verts[i].lightmap[j] );
00349         }
00350         R_ColorShiftLightingBytes( verts[i].color, (byte *)&cv->points[i][7] );
00351     }
00352 
00353     indexes += LittleLong( ds->firstIndex );
00354     for ( i = 0 ; i < numIndexes ; i++ ) {
00355         ((int *)((byte *)cv + cv->ofsIndices ))[i] = LittleLong( indexes[ i ] );
00356     }
00357 
00358     // take the plane information from the lightmap vector
00359     for ( i = 0 ; i < 3 ; i++ ) {
00360         cv->plane.normal[i] = LittleFloat( ds->lightmapVecs[2][i] );
00361     }
00362     cv->plane.dist = DotProduct( cv->points[0], cv->plane.normal );
00363     SetPlaneSignbits( &cv->plane );
00364     cv->plane.type = PlaneTypeForNormal( cv->plane.normal );
00365 
00366     surf->data = (surfaceType_t *)cv;
00367 }

Here is the call graph for this function:

void ParseFlare dsurface_t ds,
drawVert_t verts,
msurface_t surf,
int *  indexes
[static]
 

Definition at line 501 of file tr_bsp.c.

References msurface_s::data, trGlobals_t::defaultShader, msurface_s::fogIndex, dsurface_t::fogNum, h_low, refimport_t::Hunk_Alloc, i, cvar_s::integer, shader_s::isSky, LIGHTMAP_BY_VERTEX, dsurface_t::lightmapOrigin, dsurface_t::lightmapVecs, LittleFloat(), LittleLong(), msurface_t, r_singleShader, ri, msurface_s::shader, ShaderForShaderNum(), dsurface_t::shaderNum, srfFlare_t, surfaceType_t, and tr.

Referenced by R_LoadSurfaces().

00501                                                                                             {
00502     srfFlare_t      *flare;
00503     int             i;
00504 
00505     // get fog volume
00506     surf->fogIndex = LittleLong( ds->fogNum ) + 1;
00507 
00508     // get shader
00509     surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX );
00510     if ( r_singleShader->integer && !surf->shader->isSky ) {
00511         surf->shader = tr.defaultShader;
00512     }
00513 
00514     flare = ri.Hunk_Alloc( sizeof( *flare ), h_low );
00515     flare->surfaceType = SF_FLARE;
00516 
00517     surf->data = (surfaceType_t *)flare;
00518 
00519     for ( i = 0 ; i < 3 ; i++ ) {
00520         flare->origin[i] = LittleFloat( ds->lightmapOrigin[i] );
00521         flare->color[i] = LittleFloat( ds->lightmapVecs[0][i] );
00522         flare->normal[i] = LittleFloat( ds->lightmapVecs[2][i] );
00523     }
00524 }

Here is the call graph for this function:

void ParseMesh dsurface_t ds,
drawVert_t verts,
msurface_t surf
[static]
 

Definition at line 375 of file tr_bsp.c.

References msurface_s::data, trGlobals_t::defaultShader, f, dsurface_t::firstVert, msurface_s::fogIndex, dsurface_t::fogNum, height, i, cvar_s::integer, shader_s::isSky, j, drawVert_t::lightmap, dsurface_t::lightmapNum, dsurface_t::lightmapVecs, LittleFloat(), LittleLong(), srfGridMesh_s::lodOrigin, srfGridMesh_s::lodRadius, MAX_PATCH_SIZE, msurface_t, drawVert_t::normal, dsurface_t::patchHeight, dsurface_t::patchWidth, points, R_ColorShiftLightingBytes(), r_singleShader, R_SubdividePatchToGrid(), s_worldData, msurface_s::shader, ShaderForShaderNum(), dsurface_t::shaderNum, world_t::shaders, srfGridMesh_t, drawVert_t::st, dshader_t::surfaceFlags, surfaceType_t, tr, vec3_t, VectorAdd, VectorLength(), VectorScale, VectorSubtract, width, and drawVert_t::xyz.

Referenced by R_LoadSurfaces().

00375                                                                               {
00376     srfGridMesh_t   *grid;
00377     int             i, j;
00378     int             width, height, numPoints;
00379     MAC_STATIC drawVert_t points[MAX_PATCH_SIZE*MAX_PATCH_SIZE];
00380     int             lightmapNum;
00381     vec3_t          bounds[2];
00382     vec3_t          tmpVec;
00383     static surfaceType_t    skipData = SF_SKIP;
00384 
00385     lightmapNum = LittleLong( ds->lightmapNum );
00386 
00387     // get fog volume
00388     surf->fogIndex = LittleLong( ds->fogNum ) + 1;
00389 
00390     // get shader value
00391     surf->shader = ShaderForShaderNum( ds->shaderNum, lightmapNum );
00392     if ( r_singleShader->integer && !surf->shader->isSky ) {
00393         surf->shader = tr.defaultShader;
00394     }
00395 
00396     // we may have a nodraw surface, because they might still need to
00397     // be around for movement clipping
00398     if ( s_worldData.shaders[ LittleLong( ds->shaderNum ) ].surfaceFlags & SURF_NODRAW ) {
00399         surf->data = &skipData;
00400         return;
00401     }
00402 
00403     width = LittleLong( ds->patchWidth );
00404     height = LittleLong( ds->patchHeight );
00405 
00406     verts += LittleLong( ds->firstVert );
00407     numPoints = width * height;
00408     for ( i = 0 ; i < numPoints ; i++ ) {
00409         for ( j = 0 ; j < 3 ; j++ ) {
00410             points[i].xyz[j] = LittleFloat( verts[i].xyz[j] );
00411             points[i].normal[j] = LittleFloat( verts[i].normal[j] );
00412         }
00413         for ( j = 0 ; j < 2 ; j++ ) {
00414             points[i].st[j] = LittleFloat( verts[i].st[j] );
00415             points[i].lightmap[j] = LittleFloat( verts[i].lightmap[j] );
00416         }
00417         R_ColorShiftLightingBytes( verts[i].color, points[i].color );
00418     }
00419 
00420     // pre-tesseleate
00421     grid = R_SubdividePatchToGrid( width, height, points );
00422     surf->data = (surfaceType_t *)grid;
00423 
00424     // copy the level of detail origin, which is the center
00425     // of the group of all curves that must subdivide the same
00426     // to avoid cracking
00427     for ( i = 0 ; i < 3 ; i++ ) {
00428         bounds[0][i] = LittleFloat( ds->lightmapVecs[0][i] );
00429         bounds[1][i] = LittleFloat( ds->lightmapVecs[1][i] );
00430     }
00431     VectorAdd( bounds[0], bounds[1], bounds[1] );
00432     VectorScale( bounds[1], 0.5f, grid->lodOrigin );
00433     VectorSubtract( bounds[0], grid->lodOrigin, tmpVec );
00434     grid->lodRadius = VectorLength( tmpVec );
00435 }

Here is the call graph for this function:

void ParseTriSurf dsurface_t ds,
drawVert_t verts,
msurface_t surf,
int *  indexes
[static]
 

Definition at line 442 of file tr_bsp.c.

References AddPointToBounds(), ClearBounds(), drawVert_t::color, msurface_s::data, trGlobals_t::defaultShader, ERR_DROP, dsurface_t::firstIndex, dsurface_t::firstVert, msurface_s::fogIndex, dsurface_t::fogNum, h_low, refimport_t::Hunk_Alloc, i, cvar_s::integer, shader_s::isSky, j, drawVert_t::lightmap, LIGHTMAP_BY_VERTEX, LittleFloat(), LittleLong(), msurface_t, drawVert_t::normal, dsurface_t::numIndexes, dsurface_t::numVerts, R_ColorShiftLightingBytes(), r_singleShader, ri, msurface_s::shader, ShaderForShaderNum(), dsurface_t::shaderNum, drawVert_t::st, surfaceType_t, tr, and drawVert_t::xyz.

Referenced by R_LoadSurfaces().

00442                                                                                               {
00443     srfTriangles_t  *tri;
00444     int             i, j;
00445     int             numVerts, numIndexes;
00446 
00447     // get fog volume
00448     surf->fogIndex = LittleLong( ds->fogNum ) + 1;
00449 
00450     // get shader
00451     surf->shader = ShaderForShaderNum( ds->shaderNum, LIGHTMAP_BY_VERTEX );
00452     if ( r_singleShader->integer && !surf->shader->isSky ) {
00453         surf->shader = tr.defaultShader;
00454     }
00455 
00456     numVerts = LittleLong( ds->numVerts );
00457     numIndexes = LittleLong( ds->numIndexes );
00458 
00459     tri = ri.Hunk_Alloc( sizeof( *tri ) + numVerts * sizeof( tri->verts[0] ) 
00460         + numIndexes * sizeof( tri->indexes[0] ), h_low );
00461     tri->surfaceType = SF_TRIANGLES;
00462     tri->numVerts = numVerts;
00463     tri->numIndexes = numIndexes;
00464     tri->verts = (drawVert_t *)(tri + 1);
00465     tri->indexes = (int *)(tri->verts + tri->numVerts );
00466 
00467     surf->data = (surfaceType_t *)tri;
00468 
00469     // copy vertexes
00470     ClearBounds( tri->bounds[0], tri->bounds[1] );
00471     verts += LittleLong( ds->firstVert );
00472     for ( i = 0 ; i < numVerts ; i++ ) {
00473         for ( j = 0 ; j < 3 ; j++ ) {
00474             tri->verts[i].xyz[j] = LittleFloat( verts[i].xyz[j] );
00475             tri->verts[i].normal[j] = LittleFloat( verts[i].normal[j] );
00476         }
00477         AddPointToBounds( tri->verts[i].xyz, tri->bounds[0], tri->bounds[1] );
00478         for ( j = 0 ; j < 2 ; j++ ) {
00479             tri->verts[i].st[j] = LittleFloat( verts[i].st[j] );
00480             tri->verts[i].lightmap[j] = LittleFloat( verts[i].lightmap[j] );
00481         }
00482 
00483         R_ColorShiftLightingBytes( verts[i].color, tri->verts[i].color );
00484     }
00485 
00486     // copy indexes
00487     indexes += LittleLong( ds->firstIndex );
00488     for ( i = 0 ; i < numIndexes ; i++ ) {
00489         tri->indexes[i] = LittleLong( indexes[i] );
00490         if ( tri->indexes[i] < 0 || tri->indexes[i] >= numVerts ) {
00491             ri.Error( ERR_DROP, "Bad index in triangle surface" );
00492         }
00493     }
00494 }

Here is the call graph for this function:

void R_ColorShiftLightingBytes byte  in[4],
byte  out[4]
[static]
 

Definition at line 100 of file tr_bsp.c.

References b, byte, g(), in, cvar_s::integer, max, trGlobals_t::overbrightBits, r, r_mapOverBrightBits, shift, and tr.

Referenced by ParseFace(), ParseMesh(), ParseTriSurf(), R_LoadLightGrid(), and R_LoadLightmaps().

00100                                                                   {
00101     int     shift, r, g, b;
00102 
00103     // shift the color data based on overbright range
00104     shift = r_mapOverBrightBits->integer - tr.overbrightBits;
00105 
00106     // shift the data based on overbright range
00107     r = in[0] << shift;
00108     g = in[1] << shift;
00109     b = in[2] << shift;
00110     
00111     // normalize by color instead of saturating to white
00112     if ( ( r | g | b ) > 255 ) {
00113         int     max;
00114 
00115         max = r > g ? r : g;
00116         max = max > b ? max : b;
00117         r = r * 255 / max;
00118         g = g * 255 / max;
00119         b = b * 255 / max;
00120     }
00121 
00122     out[0] = r;
00123     out[1] = g;
00124     out[2] = b;
00125     out[3] = in[3];
00126 }

Here is the call graph for this function:

void R_FixSharedVertexLodError void   ) 
 

Definition at line 690 of file tr_bsp.c.

References msurface_s::data, i, srfGridMesh_s::lodFixed, world_t::numsurfaces, R_FixSharedVertexLodError_r(), s_worldData, srfGridMesh_t, world_t::surfaces, and srfGridMesh_s::surfaceType.

Referenced by R_LoadSurfaces().

00690                                        {
00691     int i;
00692     srfGridMesh_t *grid1;
00693 
00694     for ( i = 0; i < s_worldData.numsurfaces; i++ ) {
00695         //
00696         grid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data;
00697         // if this surface is not a grid
00698         if ( grid1->surfaceType != SF_GRID )
00699             continue;
00700         //
00701         if ( grid1->lodFixed )
00702             continue;
00703         //
00704         grid1->lodFixed = 2;
00705         // recursively fix other patches in the same LOD group
00706         R_FixSharedVertexLodError_r( i + 1, grid1);
00707     }
00708 }

Here is the call graph for this function:

void R_FixSharedVertexLodError_r int  start,
srfGridMesh_t grid1
 

Definition at line 578 of file tr_bsp.c.

References msurface_s::data, fabs(), srfGridMesh_s::height, srfGridMesh_s::heightLodError, j, k, l, srfGridMesh_s::lodFixed, srfGridMesh_s::lodOrigin, srfGridMesh_s::lodRadius, m, n, world_t::numsurfaces, R_MergedHeightPoints(), R_MergedWidthPoints(), s_worldData, srfGridMesh_t, world_t::surfaces, srfGridMesh_s::surfaceType, srfGridMesh_s::verts, srfGridMesh_s::width, srfGridMesh_s::widthLodError, and drawVert_t::xyz.

Referenced by R_FixSharedVertexLodError().

00578                                                                     {
00579     int j, k, l, m, n, offset1, offset2, touch;
00580     srfGridMesh_t *grid2;
00581 
00582     for ( j = start; j < s_worldData.numsurfaces; j++ ) {
00583         //
00584         grid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data;
00585         // if this surface is not a grid
00586         if ( grid2->surfaceType != SF_GRID ) continue;
00587         // if the LOD errors are already fixed for this patch
00588         if ( grid2->lodFixed == 2 ) continue;
00589         // grids in the same LOD group should have the exact same lod radius
00590         if ( grid1->lodRadius != grid2->lodRadius ) continue;
00591         // grids in the same LOD group should have the exact same lod origin
00592         if ( grid1->lodOrigin[0] != grid2->lodOrigin[0] ) continue;
00593         if ( grid1->lodOrigin[1] != grid2->lodOrigin[1] ) continue;
00594         if ( grid1->lodOrigin[2] != grid2->lodOrigin[2] ) continue;
00595         //
00596         touch = qfalse;
00597         for (n = 0; n < 2; n++) {
00598             //
00599             if (n) offset1 = (grid1->height-1) * grid1->width;
00600             else offset1 = 0;
00601             if (R_MergedWidthPoints(grid1, offset1)) continue;
00602             for (k = 1; k < grid1->width-1; k++) {
00603                 for (m = 0; m < 2; m++) {
00604 
00605                     if (m) offset2 = (grid2->height-1) * grid2->width;
00606                     else offset2 = 0;
00607                     if (R_MergedWidthPoints(grid2, offset2)) continue;
00608                     for ( l = 1; l < grid2->width-1; l++) {
00609                     //
00610                         if ( fabs(grid1->verts[k + offset1].xyz[0] - grid2->verts[l + offset2].xyz[0]) > .1) continue;
00611                         if ( fabs(grid1->verts[k + offset1].xyz[1] - grid2->verts[l + offset2].xyz[1]) > .1) continue;
00612                         if ( fabs(grid1->verts[k + offset1].xyz[2] - grid2->verts[l + offset2].xyz[2]) > .1) continue;
00613                         // ok the points are equal and should have the same lod error
00614                         grid2->widthLodError[l] = grid1->widthLodError[k];
00615                         touch = qtrue;
00616                     }
00617                 }
00618                 for (m = 0; m < 2; m++) {
00619 
00620                     if (m) offset2 = grid2->width-1;
00621                     else offset2 = 0;
00622                     if (R_MergedHeightPoints(grid2, offset2)) continue;
00623                     for ( l = 1; l < grid2->height-1; l++) {
00624                     //
00625                         if ( fabs(grid1->verts[k + offset1].xyz[0] - grid2->verts[grid2->width * l + offset2].xyz[0]) > .1) continue;
00626                         if ( fabs(grid1->verts[k + offset1].xyz[1] - grid2->verts[grid2->width * l + offset2].xyz[1]) > .1) continue;
00627                         if ( fabs(grid1->verts[k + offset1].xyz[2] - grid2->verts[grid2->width * l + offset2].xyz[2]) > .1) continue;
00628                         // ok the points are equal and should have the same lod error
00629                         grid2->heightLodError[l] = grid1->widthLodError[k];
00630                         touch = qtrue;
00631                     }
00632                 }
00633             }
00634         }
00635         for (n = 0; n < 2; n++) {
00636             //
00637             if (n) offset1 = grid1->width-1;
00638             else offset1 = 0;
00639             if (R_MergedHeightPoints(grid1, offset1)) continue;
00640             for (k = 1; k < grid1->height-1; k++) {
00641                 for (m = 0; m < 2; m++) {
00642 
00643                     if (m) offset2 = (grid2->height-1) * grid2->width;
00644                     else offset2 = 0;
00645                     if (R_MergedWidthPoints(grid2, offset2)) continue;
00646                     for ( l = 1; l < grid2->width-1; l++) {
00647                     //
00648                         if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[0] - grid2->verts[l + offset2].xyz[0]) > .1) continue;
00649                         if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[1] - grid2->verts[l + offset2].xyz[1]) > .1) continue;
00650                         if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[2] - grid2->verts[l + offset2].xyz[2]) > .1) continue;
00651                         // ok the points are equal and should have the same lod error
00652                         grid2->widthLodError[l] = grid1->heightLodError[k];
00653                         touch = qtrue;
00654                     }
00655                 }
00656                 for (m = 0; m < 2; m++) {
00657 
00658                     if (m) offset2 = grid2->width-1;
00659                     else offset2 = 0;
00660                     if (R_MergedHeightPoints(grid2, offset2)) continue;
00661                     for ( l = 1; l < grid2->height-1; l++) {
00662                     //
00663                         if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[0] - grid2->verts[grid2->width * l + offset2].xyz[0]) > .1) continue;
00664                         if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[1] - grid2->verts[grid2->width * l + offset2].xyz[1]) > .1) continue;
00665                         if ( fabs(grid1->verts[grid1->width * k + offset1].xyz[2] - grid2->verts[grid2->width * l + offset2].xyz[2]) > .1) continue;
00666                         // ok the points are equal and should have the same lod error
00667                         grid2->heightLodError[l] = grid1->heightLodError[k];
00668                         touch = qtrue;
00669                     }
00670                 }
00671             }
00672         }
00673         if (touch) {
00674             grid2->lodFixed = 2;
00675             R_FixSharedVertexLodError_r ( start, grid2 );
00676             //NOTE: this would be correct but makes things really slow
00677             //grid2->lodFixed = 1;
00678         }
00679     }
00680 }

Here is the call graph for this function:

qboolean R_GetEntityToken char *  buffer,
int  size
 

Definition at line 1769 of file tr_bsp.c.

References buffer, COM_Parse(), world_t::entityParsePoint, world_t::entityString, Q_strncpyz(), qboolean, s, and s_worldData.

01769                                                     {
01770     const char  *s;
01771 
01772     s = COM_Parse( &s_worldData.entityParsePoint );
01773     Q_strncpyz( buffer, s, size );
01774     if ( !s_worldData.entityParsePoint || !s[0] ) {
01775         s_worldData.entityParsePoint = s_worldData.entityString;
01776         return qfalse;
01777     } else {
01778         return qtrue;
01779     }
01780 }

Here is the call graph for this function:

void R_LoadEntities lump_t l  ) 
 

Definition at line 1689 of file tr_bsp.c.

References COM_ParseExt(), world_t::entityParsePoint, world_t::entityString, fileBase, lump_t::filelen, lump_t::fileofs, h_low, refimport_t::Hunk_Alloc, cvar_s::integer, l, world_t::lightGridSize, p, PRINT_WARNING, Q_stricmp(), Q_strncmp(), Q_strncpyz(), qtrue, R_RemapShader(), r_vertexLight, ri, s, sscanf(), strchr(), strcpy(), strlen(), token, value, and w.

Referenced by RE_LoadWorldMap().

01689                                  {
01690     char *p, *token, *s;
01691     char keyname[MAX_TOKEN_CHARS];
01692     char value[MAX_TOKEN_CHARS];
01693     world_t *w;
01694 
01695     w = &s_worldData;
01696     w->lightGridSize[0] = 64;
01697     w->lightGridSize[1] = 64;
01698     w->lightGridSize[2] = 128;
01699 
01700     p = (char *)(fileBase + l->fileofs);
01701 
01702     // store for reference by the cgame
01703     w->entityString = ri.Hunk_Alloc( l->filelen + 1, h_low );
01704     strcpy( w->entityString, p );
01705     w->entityParsePoint = w->entityString;
01706 
01707     token = COM_ParseExt( &p, qtrue );
01708     if (!*token || *token != '{') {
01709         return;
01710     }
01711 
01712     // only parse the world spawn
01713     while ( 1 ) {   
01714         // parse key
01715         token = COM_ParseExt( &p, qtrue );
01716 
01717         if ( !*token || *token == '}' ) {
01718             break;
01719         }
01720         Q_strncpyz(keyname, token, sizeof(keyname));
01721 
01722         // parse value
01723         token = COM_ParseExt( &p, qtrue );
01724 
01725         if ( !*token || *token == '}' ) {
01726             break;
01727         }
01728         Q_strncpyz(value, token, sizeof(value));
01729 
01730         // check for remapping of shaders for vertex lighting
01731         s = "vertexremapshader";
01732         if (!Q_strncmp(keyname, s, strlen(s)) ) {
01733             s = strchr(value, ';');
01734             if (!s) {
01735                 ri.Printf( PRINT_WARNING, "WARNING: no semi colon in vertexshaderremap '%s'\n", value );
01736                 break;
01737             }
01738             *s++ = 0;
01739             if (r_vertexLight->integer) {
01740                 R_RemapShader(value, s, "0");
01741             }
01742             continue;
01743         }
01744         // check for remapping of shaders
01745         s = "remapshader";
01746         if (!Q_strncmp(keyname, s, strlen(s)) ) {
01747             s = strchr(value, ';');
01748             if (!s) {
01749                 ri.Printf( PRINT_WARNING, "WARNING: no semi colon in shaderremap '%s'\n", value );
01750                 break;
01751             }
01752             *s++ = 0;
01753             R_RemapShader(value, s, "0");
01754             continue;
01755         }
01756         // check for a different grid size
01757         if (!Q_stricmp(keyname, "gridsize")) {
01758             sscanf(value, "%f %f %f", &w->lightGridSize[0], &w->lightGridSize[1], &w->lightGridSize[2] );
01759             continue;
01760         }
01761     }
01762 }

Here is the call graph for this function:

void R_LoadFogs lump_t l,
lump_t brushesLump,
lump_t sidesLump
[static]
 

Definition at line 1529 of file tr_bsp.c.

References dfog_t::brushNum, fogParms_t::color, ColorBytes4(), count, d, fogParms_t::depthForOpaque, cplane_s::dist, ERR_DROP, fileBase, lump_t::filelen, lump_t::fileofs, dbrush_t::firstSide, shader_s::fogParms, world_t::fogs, h_low, refimport_t::Hunk_Alloc, i, trGlobals_t::identityLight, l, LIGHTMAP_NONE, LittleLong(), world_t::name, cplane_s::normal, world_t::numfogs, world_t::planes, qtrue, R_FindShader(), ri, s_worldData, dfog_t::shader, shader_t, tr, vec3_origin, VectorSubtract, and dfog_t::visibleSide.

Referenced by RE_LoadWorldMap().

01529                                                                              {
01530     int         i;
01531     fog_t       *out;
01532     dfog_t      *fogs;
01533     dbrush_t    *brushes, *brush;
01534     dbrushside_t    *sides;
01535     int         count, brushesCount, sidesCount;
01536     int         sideNum;
01537     int         planeNum;
01538     shader_t    *shader;
01539     float       d;
01540     int         firstSide;
01541 
01542     fogs = (void *)(fileBase + l->fileofs);
01543     if (l->filelen % sizeof(*fogs)) {
01544         ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01545     }
01546     count = l->filelen / sizeof(*fogs);
01547 
01548     // create fog strucutres for them
01549     s_worldData.numfogs = count + 1;
01550     s_worldData.fogs = ri.Hunk_Alloc ( s_worldData.numfogs*sizeof(*out), h_low);
01551     out = s_worldData.fogs + 1;
01552 
01553     if ( !count ) {
01554         return;
01555     }
01556 
01557     brushes = (void *)(fileBase + brushesLump->fileofs);
01558     if (brushesLump->filelen % sizeof(*brushes)) {
01559         ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01560     }
01561     brushesCount = brushesLump->filelen / sizeof(*brushes);
01562 
01563     sides = (void *)(fileBase + sidesLump->fileofs);
01564     if (sidesLump->filelen % sizeof(*sides)) {
01565         ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01566     }
01567     sidesCount = sidesLump->filelen / sizeof(*sides);
01568 
01569     for ( i=0 ; i<count ; i++, fogs++) {
01570         out->originalBrushNumber = LittleLong( fogs->brushNum );
01571 
01572         if ( (unsigned)out->originalBrushNumber >= brushesCount ) {
01573             ri.Error( ERR_DROP, "fog brushNumber out of range" );
01574         }
01575         brush = brushes + out->originalBrushNumber;
01576 
01577         firstSide = LittleLong( brush->firstSide );
01578 
01579             if ( (unsigned)firstSide > sidesCount - 6 ) {
01580             ri.Error( ERR_DROP, "fog brush sideNumber out of range" );
01581         }
01582 
01583         // brushes are always sorted with the axial sides first
01584         sideNum = firstSide + 0;
01585         planeNum = LittleLong( sides[ sideNum ].planeNum );
01586         out->bounds[0][0] = -s_worldData.planes[ planeNum ].dist;
01587 
01588         sideNum = firstSide + 1;
01589         planeNum = LittleLong( sides[ sideNum ].planeNum );
01590         out->bounds[1][0] = s_worldData.planes[ planeNum ].dist;
01591 
01592         sideNum = firstSide + 2;
01593         planeNum = LittleLong( sides[ sideNum ].planeNum );
01594         out->bounds[0][1] = -s_worldData.planes[ planeNum ].dist;
01595 
01596         sideNum = firstSide + 3;
01597         planeNum = LittleLong( sides[ sideNum ].planeNum );
01598         out->bounds[1][1] = s_worldData.planes[ planeNum ].dist;
01599 
01600         sideNum = firstSide + 4;
01601         planeNum = LittleLong( sides[ sideNum ].planeNum );
01602         out->bounds[0][2] = -s_worldData.planes[ planeNum ].dist;
01603 
01604         sideNum = firstSide + 5;
01605         planeNum = LittleLong( sides[ sideNum ].planeNum );
01606         out->bounds[1][2] = s_worldData.planes[ planeNum ].dist;
01607 
01608         // get information from the shader for fog parameters
01609         shader =