#include "tr_local.h"
Include dependency graph for tr_bsp.c:

Go to the source code of this file.
|
|
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(). |
|
||||||||||||||||||||
|
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:

|
||||||||||||||||||||
|
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:

|
||||||||||||||||||||
Here is the call graph for this function:

|
||||||||||||||||
|
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:

|
||||||||||||||||||||
|
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:

|
||||||||||||
|
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:

|
|
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:

|
||||||||||||
|
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:

|
||||||||||||
|
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:

|
|
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:

|
||||||||||||||||
|
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 = R_FindShader( fogs->shader, LIGHTMAP_NONE, qtrue );
01610
01611 out->parms = shader->fogParms;
01612
01613 out->colorInt = ColorBytes4 ( shader->fogParms.color[0] * tr.identityLight,
01614 shader->fogParms.color[1] * tr.identityLight,
01615 shader->fogParms.color[2] * tr.identityLight, 1.0 );
01616
01617 d = shader->fogParms.depthForOpaque < 1 ? 1 : shader->fogParms.depthForOpaque;
01618 out->tcScale = 1.0f / ( d * 8 );
01619
01620 // set the gradient vector
01621 sideNum = LittleLong( fogs->visibleSide );
01622
01623 if ( sideNum == -1 ) {
01624 out->hasSurface = qfalse;
01625 } else {
01626 out->hasSurface = qtrue;
01627 planeNum = LittleLong( sides[ firstSide + sideNum ].planeNum );
01628 VectorSubtract( vec3_origin, s_worldData.planes[ planeNum ].normal, out->surface );
01629 out->surface[3] = -s_worldData.planes[ planeNum ].dist;
01630 }
01631
01632 out++;
01633 }
01634
01635 }
|
Here is the call graph for this function:

|
|
Definition at line 1644 of file tr_bsp.c. References world_t::bmodels, bmodel_t::bounds, ceil(), Com_Memcpy(), fileBase, lump_t::filelen, lump_t::fileofs, floor(), h_low, refimport_t::Hunk_Alloc, i, l, world_t::lightGridBounds, world_t::lightGridData, world_t::lightGridInverseSize, world_t::lightGridOrigin, world_t::lightGridSize, numGridPoints, PRINT_WARNING, R_ColorShiftLightingBytes(), ri, vec3_t, and w. Referenced by RE_LoadWorldMap(). 01644 {
01645 int i;
01646 vec3_t maxs;
01647 int numGridPoints;
01648 world_t *w;
01649 float *wMins, *wMaxs;
01650
01651 w = &s_worldData;
01652
01653 w->lightGridInverseSize[0] = 1.0f / w->lightGridSize[0];
01654 w->lightGridInverseSize[1] = 1.0f / w->lightGridSize[1];
01655 w->lightGridInverseSize[2] = 1.0f / w->lightGridSize[2];
01656
01657 wMins = w->bmodels[0].bounds[0];
01658 wMaxs = w->bmodels[0].bounds[1];
01659
01660 for ( i = 0 ; i < 3 ; i++ ) {
01661 w->lightGridOrigin[i] = w->lightGridSize[i] * ceil( wMins[i] / w->lightGridSize[i] );
01662 maxs[i] = w->lightGridSize[i] * floor( wMaxs[i] / w->lightGridSize[i] );
01663 w->lightGridBounds[i] = (maxs[i] - w->lightGridOrigin[i])/w->lightGridSize[i] + 1;
01664 }
01665
01666 numGridPoints = w->lightGridBounds[0] * w->lightGridBounds[1] * w->lightGridBounds[2];
01667
01668 if ( l->filelen != numGridPoints * 8 ) {
01669 ri.Printf( PRINT_WARNING, "WARNING: light grid mismatch\n" );
01670 w->lightGridData = NULL;
01671 return;
01672 }
01673
01674 w->lightGridData = ri.Hunk_Alloc( l->filelen, h_low );
01675 Com_Memcpy( w->lightGridData, (void *)(fileBase + l->fileofs), l->filelen );
01676
01677 // deal with overbright bits
01678 for ( i = 0 ; i < numGridPoints ; i++ ) {
01679 R_ColorShiftLightingBytes( &w->lightGridData[i*8], &w->lightGridData[i*8] );
01680 R_ColorShiftLightingBytes( &w->lightGridData[i*8+3], &w->lightGridData[i*8+3] );
01681 }
01682 }
|
Here is the call graph for this function:

|
|
Definition at line 135 of file tr_bsp.c. References b, byte, fileBase, lump_t::filelen, lump_t::fileofs, g(), glConfig, glconfig_t::hardwareType, HSVtoRGB(), i, cvar_s::integer, j, l, LIGHTMAP_SIZE, trGlobals_t::lightmaps, trGlobals_t::numLightmaps, PRINT_ALL, qfalse, r, R_ColorShiftLightingBytes(), R_CreateImage(), r_lightmap, R_SyncRenderThread(), r_vertexLight, ri, tr, and va(). Referenced by RE_LoadWorldMap(). 00135 {
00136 byte *buf, *buf_p;
00137 int len;
00138 MAC_STATIC byte image[LIGHTMAP_SIZE*LIGHTMAP_SIZE*4];
00139 int i, j;
00140 float maxIntensity = 0;
00141 double sumIntensity = 0;
00142
00143 len = l->filelen;
00144 if ( !len ) {
00145 return;
00146 }
00147 buf = fileBase + l->fileofs;
00148
00149 // we are about to upload textures
00150 R_SyncRenderThread();
00151
00152 // create all the lightmaps
00153 tr.numLightmaps = len / (LIGHTMAP_SIZE * LIGHTMAP_SIZE * 3);
00154 if ( tr.numLightmaps == 1 ) {
00155 //FIXME: HACK: maps with only one lightmap turn up fullbright for some reason.
00156 //this avoids this, but isn't the correct solution.
00157 tr.numLightmaps++;
00158 }
00159
00160 // if we are in r_vertexLight mode, we don't need the lightmaps at all
00161 if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) {
00162 return;
00163 }
00164
00165 for ( i = 0 ; i < tr.numLightmaps ; i++ ) {
00166 // expand the 24 bit on-disk to 32 bit
00167 buf_p = buf + i * LIGHTMAP_SIZE*LIGHTMAP_SIZE * 3;
00168
00169 if ( r_lightmap->integer == 2 )
00170 { // color code by intensity as development tool (FIXME: check range)
00171 for ( j = 0; j < LIGHTMAP_SIZE * LIGHTMAP_SIZE; j++ )
00172 {
00173 float r = buf_p[j*3+0];
00174 float g = buf_p[j*3+1];
00175 float b = buf_p[j*3+2];
00176 float intensity;
00177 float out[3];
00178
00179 intensity = 0.33f * r + 0.685f * g + 0.063f * b;
00180
00181 if ( intensity > 255 )
00182 intensity = 1.0f;
00183 else
00184 intensity /= 255.0f;
00185
00186 if ( intensity > maxIntensity )
00187 maxIntensity = intensity;
00188
00189 HSVtoRGB( intensity, 1.00, 0.50, out );
00190
00191 image[j*4+0] = out[0] * 255;
00192 image[j*4+1] = out[1] * 255;
00193 image[j*4+2] = out[2] * 255;
00194 image[j*4+3] = 255;
00195
00196 sumIntensity += intensity;
00197 }
00198 } else {
00199 for ( j = 0 ; j < LIGHTMAP_SIZE * LIGHTMAP_SIZE; j++ ) {
00200 R_ColorShiftLightingBytes( &buf_p[j*3], &image[j*4] );
00201 image[j*4+3] = 255;
00202 }
00203 }
00204 tr.lightmaps[i] = R_CreateImage( va("*lightmap%d",i), image,
00205 LIGHTMAP_SIZE, LIGHTMAP_SIZE, qfalse, qfalse, GL_CLAMP );
00206 }
00207
00208 if ( r_lightmap->integer == 2 ) {
00209 ri.Printf( PRINT_ALL, "Brightest lightmap value: %d\n", ( int ) ( maxIntensity * 255 ) );
00210 }
00211 }
|
Here is the call graph for this function:

|
|
Definition at line 1464 of file tr_bsp.c. References count, ERR_DROP, fileBase, lump_t::filelen, lump_t::fileofs, h_low, refimport_t::Hunk_Alloc, i, in, j, l, LittleLong(), world_t::marksurfaces, msurface_t, world_t::name, world_t::nummarksurfaces, ri, s_worldData, and world_t::surfaces. Referenced by RE_LoadWorldMap(). 01465 {
01466 int i, j, count;
01467 int *in;
01468 msurface_t **out;
01469
01470 in = (void *)(fileBase + l->fileofs);
01471 if (l->filelen % sizeof(*in))
01472 ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01473 count = l->filelen / sizeof(*in);
01474 out = ri.Hunk_Alloc ( count*sizeof(*out), h_low);
01475
01476 s_worldData.marksurfaces = out;
01477 s_worldData.nummarksurfaces = count;
01478
01479 for ( i=0 ; i<count ; i++)
01480 {
01481 j = LittleLong(in[i]);
01482 out[i] = s_worldData.surfaces + j;
01483 }
01484 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1359 of file tr_bsp.c. References mnode_s::children, ERR_DROP, fileBase, lump_t::filelen, lump_t::fileofs, h_low, refimport_t::Hunk_Alloc, i, in, j, LittleLong(), world_t::marksurfaces, dleaf_t::mins, mnode_t, world_t::name, world_t::nodes, NULL, world_t::numClusters, world_t::numDecisionNodes, world_t::numnodes, p, world_t::planes, R_SetParent(), ri, and s_worldData. Referenced by RE_LoadWorldMap(). 01359 {
01360 int i, j, p;
01361 dnode_t *in;
01362 dleaf_t *inLeaf;
01363 mnode_t *out;
01364 int numNodes, numLeafs;
01365
01366 in = (void *)(fileBase + nodeLump->fileofs);
01367 if (nodeLump->filelen % sizeof(dnode_t) ||
01368 leafLump->filelen % sizeof(dleaf_t) ) {
01369 ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01370 }
01371 numNodes = nodeLump->filelen / sizeof(dnode_t);
01372 numLeafs = leafLump->filelen / sizeof(dleaf_t);
01373
01374 out = ri.Hunk_Alloc ( (numNodes + numLeafs) * sizeof(*out), h_low);
01375
01376 s_worldData.nodes = out;
01377 s_worldData.numnodes = numNodes + numLeafs;
01378 s_worldData.numDecisionNodes = numNodes;
01379
01380 // load nodes
01381 for ( i=0 ; i<numNodes; i++, in++, out++)
01382 {
01383 for (j=0 ; j<3 ; j++)
01384 {
01385 out->mins[j] = LittleLong (in->mins[j]);
01386 out->maxs[j] = LittleLong (in->maxs[j]);
01387 }
01388
01389 p = LittleLong(in->planeNum);
01390 out->plane = s_worldData.planes + p;
01391
01392 out->contents = CONTENTS_NODE; // differentiate from leafs
01393
01394 for (j=0 ; j<2 ; j++)
01395 {
01396 p = LittleLong (in->children[j]);
01397 if (p >= 0)
01398 out->children[j] = s_worldData.nodes + p;
01399 else
01400 out->children[j] = s_worldData.nodes + numNodes + (-1 - p);
01401 }
01402 }
01403
01404 // load leafs
01405 inLeaf = (void *)(fileBase + leafLump->fileofs);
01406 for ( i=0 ; i<numLeafs ; i++, inLeaf++, out++)
01407 {
01408 for (j=0 ; j<3 ; j++)
01409 {
01410 out->mins[j] = LittleLong (inLeaf->mins[j]);
01411 out->maxs[j] = LittleLong (inLeaf->maxs[j]);
01412 }
01413
01414 out->cluster = LittleLong(inLeaf->cluster);
01415 out->area = LittleLong(inLeaf->area);
01416
01417 if ( out->cluster >= s_worldData.numClusters ) {
01418 s_worldData.numClusters = out->cluster + 1;
01419 }
01420
01421 out->firstmarksurface = s_worldData.marksurfaces +
01422 LittleLong(inLeaf->firstLeafSurface);
01423 out->nummarksurfaces = LittleLong(inLeaf->numLeafSurfaces);
01424 }
01425
01426 // chain decendants
01427 R_SetParent (s_worldData.nodes, NULL);
01428 }
|
Here is the call graph for this function:

|
|
Definition at line 1492 of file tr_bsp.c. References bits, count, cplane_t, ERR_DROP, fileBase, lump_t::filelen, lump_t::fileofs, h_low, refimport_t::Hunk_Alloc, i, in, j, l, LittleFloat(), world_t::name, world_t::numplanes, world_t::planes, PlaneTypeForNormal, ri, and s_worldData. Referenced by RE_LoadWorldMap(). 01492 {
01493 int i, j;
01494 cplane_t *out;
01495 dplane_t *in;
01496 int count;
01497 int bits;
01498
01499 in = (void *)(fileBase + l->fileofs);
01500 if (l->filelen % sizeof(*in))
01501 ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01502 count = l->filelen / sizeof(*in);
01503 out = ri.Hunk_Alloc ( count*2*sizeof(*out), h_low);
01504
01505 s_worldData.planes = out;
01506 s_worldData.numplanes = count;
01507
01508 for ( i=0 ; i<count ; i++, in++, out++) {
01509 bits = 0;
01510 for (j=0 ; j<3 ; j++) {
01511 out->normal[j] = LittleFloat (in->normal[j]);
01512 if (out->normal[j] < 0) {
01513 bits |= 1<<j;
01514 }
01515 }
01516
01517 out->dist = LittleFloat (in->dist);
01518 out->type = PlaneTypeForNormal( out->normal );
01519 out->signbits = bits;
01520 }
01521 }
|
Here is the call graph for this function:

|
|
Definition at line 1437 of file tr_bsp.c. References Com_Memcpy(), count, ERR_DROP, fileBase, lump_t::filelen, lump_t::fileofs, h_low, refimport_t::Hunk_Alloc, i, in, l, LittleLong(), world_t::name, world_t::numShaders, ri, s_worldData, and world_t::shaders. Referenced by RE_LoadWorldMap(). 01437 {
01438 int i, count;
01439 dshader_t *in, *out;
01440
01441 in = (void *)(fileBase + l->fileofs);
01442 if (l->filelen % sizeof(*in))
01443 ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01444 count = l->filelen / sizeof(*in);
01445 out = ri.Hunk_Alloc ( count*sizeof(*out), h_low );
01446
01447 s_worldData.shaders = out;
01448 s_worldData.numShaders = count;
01449
01450 Com_Memcpy( out, in, count*sizeof(*out) );
01451
01452 for ( i=0 ; i<count ; i++ ) {
01453 out[i].surfaceFlags = LittleLong( out[i].surfaceFlags );
01454 out[i].contentFlags = LittleLong( out[i].contentFlags );
01455 }
01456 }
|
Here is the call graph for this function:

|
|
Definition at line 1303 of file tr_bsp.c. References assert, model_s::bmodel, world_t::bmodels, Com_sprintf(), count, ERR_DROP, fileBase, lump_t::filelen, lump_t::fileofs, h_low, refimport_t::Hunk_Alloc, i, in, j, l, LittleFloat(), LittleLong(), model_t, model_s::name, world_t::name, NULL, R_AllocModel(), ri, s_worldData, world_t::surfaces, and model_s::type. Referenced by RE_LoadWorldMap(). 01303 {
01304 dmodel_t *in;
01305 bmodel_t *out;
01306 int i, j, count;
01307
01308 in = (void *)(fileBase + l->fileofs);
01309 if (l->filelen % sizeof(*in))
01310 ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01311 count = l->filelen / sizeof(*in);
01312
01313 s_worldData.bmodels = out = ri.Hunk_Alloc( count * sizeof(*out), h_low );
01314
01315 for ( i=0 ; i<count ; i++, in++, out++ ) {
01316 model_t *model;
01317
01318 model = R_AllocModel();
01319
01320 assert( model != NULL ); // this should never happen
01321
01322 model->type = MOD_BRUSH;
01323 model->bmodel = out;
01324 Com_sprintf( model->name, sizeof( model->name ), "*%d", i );
01325
01326 for (j=0 ; j<3 ; j++) {
01327 out->bounds[0][j] = LittleFloat (in->mins[j]);
01328 out->bounds[1][j] = LittleFloat (in->maxs[j]);
01329 }
01330
01331 out->firstSurface = s_worldData.surfaces + LittleLong( in->firstSurface );
01332 out->numSurfaces = LittleLong( in->numSurfaces );
01333 }
01334 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 1227 of file tr_bsp.c. References count, ERR_DROP, fileBase, lump_t::filelen, lump_t::fileofs, h_low, refimport_t::Hunk_Alloc, i, in, LittleLong(), MST_FLARE, MST_PATCH, MST_PLANAR, MST_TRIANGLE_SOUP, msurface_t, world_t::name, world_t::numsurfaces, ParseFace(), ParseFlare(), ParseMesh(), ParseTriSurf(), PRINT_ALL, R_FixSharedVertexLodError(), R_MovePatchSurfacesToHunk(), R_StitchAllPatches(), ri, s_worldData, and world_t::surfaces. Referenced by RE_LoadWorldMap(). 01227 {
01228 dsurface_t *in;
01229 msurface_t *out;
01230 drawVert_t *dv;
01231 int *indexes;
01232 int count;
01233 int numFaces, numMeshes, numTriSurfs, numFlares;
01234 int i;
01235
01236 numFaces = 0;
01237 numMeshes = 0;
01238 numTriSurfs = 0;
01239 numFlares = 0;
01240
01241 in = (void *)(fileBase + surfs->fileofs);
01242 if (surfs->filelen % sizeof(*in))
01243 ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01244 count = surfs->filelen / sizeof(*in);
01245
01246 dv = (void *)(fileBase + verts->fileofs);
01247 if (verts->filelen % sizeof(*dv))
01248 ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01249
01250 indexes = (void *)(fileBase + indexLump->fileofs);
01251 if ( indexLump->filelen % sizeof(*indexes))
01252 ri.Error (ERR_DROP, "LoadMap: funny lump size in %s",s_worldData.name);
01253
01254 out = ri.Hunk_Alloc ( count * sizeof(*out), h_low );
01255
01256 s_worldData.surfaces = out;
01257 s_worldData.numsurfaces = count;
01258
01259 for ( i = 0 ; i < count ; i++, in++, out++ ) {
01260 switch ( LittleLong( in->surfaceType ) ) {
01261 case MST_PATCH:
01262 ParseMesh ( in, dv, out );
01263 numMeshes++;
01264 break;
01265 case MST_TRIANGLE_SOUP:
01266 ParseTriSurf( in, dv, out, indexes );
01267 numTriSurfs++;
01268 break;
01269 case MST_PLANAR:
01270 ParseFace( in, dv, out, indexes );
01271 numFaces++;
01272 break;
01273 case MST_FLARE:
01274 ParseFlare( in, dv, out, indexes );
01275 numFlares++;
01276 break;
01277 default:
01278 ri.Error( ERR_DROP, "Bad surfaceType" );
01279 }
01280 }
01281
01282 #ifdef PATCH_STITCHING
01283 R_StitchAllPatches();
01284 #endif
01285
01286 R_FixSharedVertexLodError();
01287
01288 #ifdef PATCH_STITCHING
01289 R_MovePatchSurfacesToHunk();
01290 #endif
01291
01292 ri.Printf( PRINT_ALL, "...loaded %d faces, %i meshes, %i trisurfs, %i flares\n",
01293 numFaces, numMeshes, numTriSurfs, numFlares );
01294 }
|
Here is the call graph for this function:

|
|
Definition at line 232 of file tr_bsp.c. References byte, world_t::clusterBytes, Com_Memcpy(), Com_Memset(), trGlobals_t::externalVisData, fileBase, lump_t::filelen, lump_t::fileofs, h_low, refimport_t::Hunk_Alloc, l, LittleLong(), world_t::novis, world_t::numClusters, ri, s_worldData, tr, and world_t::vis. Referenced by RE_LoadWorldMap(). 00232 {
00233 int len;
00234 byte *buf;
00235
00236 len = ( s_worldData.numClusters + 63 ) & ~63;
00237 s_worldData.novis = ri.Hunk_Alloc( len, h_low );
00238 Com_Memset( s_worldData.novis, 0xff, len );
00239
00240 len = l->filelen;
00241 if ( !len ) {
00242 return;
00243 }
00244 buf = fileBase + l->fileofs;
00245
00246 s_worldData.numClusters = LittleLong( ((int *)buf)[0] );
00247 s_worldData.clusterBytes = LittleLong( ((int *)buf)[1] );
00248
00249 // CM_Load should have given us the vis data to share, so
00250 // we don't need to allocate another copy
00251 if ( tr.externalVisData ) {
00252 s_worldData.vis = tr.externalVisData;
00253 } else {
00254 byte *dest;
00255
00256 dest = ri.Hunk_Alloc( len - 8, h_low );
00257 Com_Memcpy( dest, buf + 8, len - 8 );
00258 s_worldData.vis = dest;
00259 }
00260 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 555 of file tr_bsp.c. References fabs(), srfGridMesh_s::height, i, j, offset, srfGridMesh_t, srfGridMesh_s::verts, and srfGridMesh_s::width. Referenced by R_FixSharedVertexLodError_r(), and R_StitchPatches(). 00555 {
00556 int i, j;
00557
00558 for (i = 1; i < grid->height-1; i++) {
00559 for (j = i + 1; j < grid->height-1; j++) {
00560 if ( fabs(grid->verts[grid->width * i + offset].xyz[0] - grid->verts[grid->width * j + offset].xyz[0]) > .1) continue;
00561 if ( fabs(grid->verts[grid->width * i + offset].xyz[1] - grid->verts[grid->width * j + offset].xyz[1]) > .1) continue;
00562 if ( fabs(grid->verts[grid->width * i + offset].xyz[2] - grid->verts[grid->width * j + offset].xyz[2]) > .1) continue;
00563 return qtrue;
00564 }
00565 }
00566 return qfalse;
00567 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 534 of file tr_bsp.c. References fabs(), i, j, offset, srfGridMesh_t, srfGridMesh_s::verts, srfGridMesh_s::width, and drawVert_t::xyz. Referenced by R_FixSharedVertexLodError_r(), and R_StitchPatches(). 00534 {
00535 int i, j;
00536
00537 for (i = 1; i < grid->width-1; i++) {
00538 for (j = i + 1; j < grid->width-1; j++) {
00539 if ( fabs(grid->verts[i + offset].xyz[0] - grid->verts[j + offset].xyz[0]) > .1) continue;
00540 if ( fabs(grid->verts[i + offset].xyz[1] - grid->verts[j + offset].xyz[1]) > .1) continue;
00541 if ( fabs(grid->verts[i + offset].xyz[2] - grid->verts[j + offset].xyz[2]) > .1) continue;
00542 return qtrue;
00543 }
00544 }
00545 return qfalse;
00546 }
|
Here is the call graph for this function:

|
|
Definition at line 1195 of file tr_bsp.c. References Com_Memcpy(), msurface_s::data, h_low, srfGridMesh_s::height, srfGridMesh_s::heightLodError, refimport_t::Hunk_Alloc, i, world_t::numsurfaces, R_FreeSurfaceGridMesh(), ri, s_worldData, srfGridMesh_t, world_t::surfaces, srfGridMesh_s::surfaceType, srfGridMesh_s::width, and srfGridMesh_s::widthLodError. Referenced by R_LoadSurfaces(). 01195 {
01196 int i, size;
01197 srfGridMesh_t *grid, *hunkgrid;
01198
01199 for ( i = 0; i < s_worldData.numsurfaces; i++ ) {
01200 //
01201 grid = (srfGridMesh_t *) s_worldData.surfaces[i].data;
01202 // if this surface is not a grid
01203 if ( grid->surfaceType != SF_GRID )
01204 continue;
01205 //
01206 size = (grid->width * grid->height - 1) * sizeof( drawVert_t ) + sizeof( *grid );
01207 hunkgrid = ri.Hunk_Alloc( size, h_low );
01208 Com_Memcpy(hunkgrid, grid, size);
01209
01210 hunkgrid->widthLodError = ri.Hunk_Alloc( grid->width * 4, h_low );
01211 Com_Memcpy( hunkgrid->widthLodError, grid->widthLodError, grid->width * 4 );
01212
01213 hunkgrid->heightLodError = ri.Hunk_Alloc( grid->height * 4, h_low );
01214 Com_Memcpy( grid->heightLodError, grid->heightLodError, grid->height * 4 );
01215
01216 R_FreeSurfaceGridMesh( grid );
01217
01218 s_worldData.surfaces[i].data = (void *) hunkgrid;
01219 }
01220 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1345 of file tr_bsp.c. References mnode_s::children, mnode_s::contents, mnode_t, and mnode_s::parent. Referenced by R_LoadNodesAndLeafs(). 01346 {
01347 node->parent = parent;
01348 if (node->contents != -1)
01349 return;
01350 R_SetParent (node->children[0], node);
01351 R_SetParent (node->children[1], node);
01352 }
|
|
|
Definition at line 1162 of file tr_bsp.c. References msurface_s::data, i, srfGridMesh_s::lodStitched, world_t::numsurfaces, PRINT_ALL, R_TryStitchingPatch(), ri, s_worldData, srfGridMesh_t, world_t::surfaces, and srfGridMesh_s::surfaceType. Referenced by R_LoadSurfaces(). 01162 {
01163 int i, stitched, numstitches;
01164 srfGridMesh_t *grid1;
01165
01166 numstitches = 0;
01167 do
01168 {
01169 stitched = qfalse;
01170 for ( i = 0; i < s_worldData.numsurfaces; i++ ) {
01171 //
01172 grid1 = (srfGridMesh_t *) s_worldData.surfaces[i].data;
01173 // if this surface is not a grid
01174 if ( grid1->surfaceType != SF_GRID )
01175 continue;
01176 //
01177 if ( grid1->lodStitched )
01178 continue;
01179 //
01180 grid1->lodStitched = qtrue;
01181 stitched = qtrue;
01182 //
01183 numstitches += R_TryStitchingPatch( i );
01184 }
01185 }
01186 while (stitched);
01187 ri.Printf( PRINT_ALL, "stitched %d LoD cracks\n", numstitches );
01188 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 716 of file tr_bsp.c. References msurface_s::data, fabs(), srfGridMesh_s::height, srfGridMesh_s::heightLodError, k, l, srfGridMesh_s::lodStitched, m, n, R_GridInsertColumn(), R_GridInsertRow(), R_MergedHeightPoints(), R_MergedWidthPoints(), s_worldData, srfGridMesh_t, world_t::surfaces, v1, v2, srfGridMesh_s::verts, srfGridMesh_s::width, srfGridMesh_s::widthLodError, and drawVert_t::xyz. Referenced by R_TryStitchingPatch(). 00716 {
00717 float *v1, *v2;
00718 srfGridMesh_t *grid1, *grid2;
00719 int k, l, m, n, offset1, offset2, row, column;
00720
00721 grid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data;
00722 grid2 = (srfGridMesh_t *) s_worldData.surfaces[grid2num].data;
00723 for (n = 0; n < 2; n++) {
00724 //
00725 if (n) offset1 = (grid1->height-1) * grid1->width;
00726 else offset1 = 0;
00727 if (R_MergedWidthPoints(grid1, offset1))
00728 continue;
00729 for (k = 0; k < grid1->width-2; k += 2) {
00730
00731 for (m = 0; m < 2; m++) {
00732
00733 if ( grid2->width >= MAX_GRID_SIZE )
00734 break;
00735 if (m) offset2 = (grid2->height-1) * grid2->width;
00736 else offset2 = 0;
00737 for ( l = 0; l < grid2->width-1; l++) {
00738 //
00739 v1 = grid1->verts[k + offset1].xyz;
00740 v2 = grid2->verts[l + offset2].xyz;
00741 if ( fabs(v1[0] - v2[0]) > .1)
00742 continue;
00743 if ( fabs(v1[1] - v2[1]) > .1)
00744 continue;
00745 if ( fabs(v1[2] - v2[2]) > .1)
00746 continue;
00747
00748 v1 = grid1->verts[k + 2 + offset1].xyz;
00749 v2 = grid2->verts[l + 1 + offset2].xyz;
00750 if ( fabs(v1[0] - v2[0]) > .1)
00751 continue;
00752 if ( fabs(v1[1] - v2[1]) > .1)
00753 continue;
00754 if ( fabs(v1[2] - v2[2]) > .1)
00755 continue;
00756 //
00757 v1 = grid2->verts[l + offset2].xyz;
00758 v2 = grid2->verts[l + 1 + offset2].xyz;
00759 if ( fabs(v1[0] - v2[0]) < .01 &&
00760 fabs(v1[1] - v2[1]) < .01 &&
00761 fabs(v1[2] - v2[2]) < .01)
00762 continue;
00763 //
00764 //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" );
00765 // insert column into grid2 right after after column l
00766 if (m) row = grid2->height-1;
00767 else row = 0;
00768 grid2 = R_GridInsertColumn( grid2, l+1, row,
00769 grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]);
00770 grid2->lodStitched = qfalse;
00771 s_worldData.surfaces[grid2num].data = (void *) grid2;
00772 return qtrue;
00773 }
00774 }
00775 for (m = 0; m < 2; m++) {
00776
00777 if (grid2->height >= MAX_GRID_SIZE)
00778 break;
00779 if (m) offset2 = grid2->width-1;
00780 else offset2 = 0;
00781 for ( l = 0; l < grid2->height-1; l++) {
00782 //
00783 v1 = grid1->verts[k + offset1].xyz;
00784 v2 = grid2->verts[grid2->width * l + offset2].xyz;
00785 if ( fabs(v1[0] - v2[0]) > .1)
00786 continue;
00787 if ( fabs(v1[1] - v2[1]) > .1)
00788 continue;
00789 if ( fabs(v1[2] - v2[2]) > .1)
00790 continue;
00791
00792 v1 = grid1->verts[k + 2 + offset1].xyz;
00793 v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;
00794 if ( fabs(v1[0] - v2[0]) > .1)
00795 continue;
00796 if ( fabs(v1[1] - v2[1]) > .1)
00797 continue;
00798 if ( fabs(v1[2] - v2[2]) > .1)
00799 continue;
00800 //
00801 v1 = grid2->verts[grid2->width * l + offset2].xyz;
00802 v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;
00803 if ( fabs(v1[0] - v2[0]) < .01 &&
00804 fabs(v1[1] - v2[1]) < .01 &&
00805 fabs(v1[2] - v2[2]) < .01)
00806 continue;
00807 //
00808 //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" );
00809 // insert row into grid2 right after after row l
00810 if (m) column = grid2->width-1;
00811 else column = 0;
00812 grid2 = R_GridInsertRow( grid2, l+1, column,
00813 grid1->verts[k + 1 + offset1].xyz, grid1->widthLodError[k+1]);
00814 grid2->lodStitched = qfalse;
00815 s_worldData.surfaces[grid2num].data = (void *) grid2;
00816 return qtrue;
00817 }
00818 }
00819 }
00820 }
00821 for (n = 0; n < 2; n++) {
00822 //
00823 if (n) offset1 = grid1->width-1;
00824 else offset1 = 0;
00825 if (R_MergedHeightPoints(grid1, offset1))
00826 continue;
00827 for (k = 0; k < grid1->height-2; k += 2) {
00828 for (m = 0; m < 2; m++) {
00829
00830 if ( grid2->width >= MAX_GRID_SIZE )
00831 break;
00832 if (m) offset2 = (grid2->height-1) * grid2->width;
00833 else offset2 = 0;
00834 for ( l = 0; l < grid2->width-1; l++) {
00835 //
00836 v1 = grid1->verts[grid1->width * k + offset1].xyz;
00837 v2 = grid2->verts[l + offset2].xyz;
00838 if ( fabs(v1[0] - v2[0]) > .1)
00839 continue;
00840 if ( fabs(v1[1] - v2[1]) > .1)
00841 continue;
00842 if ( fabs(v1[2] - v2[2]) > .1)
00843 continue;
00844
00845 v1 = grid1->verts[grid1->width * (k + 2) + offset1].xyz;
00846 v2 = grid2->verts[l + 1 + offset2].xyz;
00847 if ( fabs(v1[0] - v2[0]) > .1)
00848 continue;
00849 if ( fabs(v1[1] - v2[1]) > .1)
00850 continue;
00851 if ( fabs(v1[2] - v2[2]) > .1)
00852 continue;
00853 //
00854 v1 = grid2->verts[l + offset2].xyz;
00855 v2 = grid2->verts[(l + 1) + offset2].xyz;
00856 if ( fabs(v1[0] - v2[0]) < .01 &&
00857 fabs(v1[1] - v2[1]) < .01 &&
00858 fabs(v1[2] - v2[2]) < .01)
00859 continue;
00860 //
00861 //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" );
00862 // insert column into grid2 right after after column l
00863 if (m) row = grid2->height-1;
00864 else row = 0;
00865 grid2 = R_GridInsertColumn( grid2, l+1, row,
00866 grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]);
00867 grid2->lodStitched = qfalse;
00868 s_worldData.surfaces[grid2num].data = (void *) grid2;
00869 return qtrue;
00870 }
00871 }
00872 for (m = 0; m < 2; m++) {
00873
00874 if (grid2->height >= MAX_GRID_SIZE)
00875 break;
00876 if (m) offset2 = grid2->width-1;
00877 else offset2 = 0;
00878 for ( l = 0; l < grid2->height-1; l++) {
00879 //
00880 v1 = grid1->verts[grid1->width * k + offset1].xyz;
00881 v2 = grid2->verts[grid2->width * l + offset2].xyz;
00882 if ( fabs(v1[0] - v2[0]) > .1)
00883 continue;
00884 if ( fabs(v1[1] - v2[1]) > .1)
00885 continue;
00886 if ( fabs(v1[2] - v2[2]) > .1)
00887 continue;
00888
00889 v1 = grid1->verts[grid1->width * (k + 2) + offset1].xyz;
00890 v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;
00891 if ( fabs(v1[0] - v2[0]) > .1)
00892 continue;
00893 if ( fabs(v1[1] - v2[1]) > .1)
00894 continue;
00895 if ( fabs(v1[2] - v2[2]) > .1)
00896 continue;
00897 //
00898 v1 = grid2->verts[grid2->width * l + offset2].xyz;
00899 v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;
00900 if ( fabs(v1[0] - v2[0]) < .01 &&
00901 fabs(v1[1] - v2[1]) < .01 &&
00902 fabs(v1[2] - v2[2]) < .01)
00903 continue;
00904 //
00905 //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" );
00906 // insert row into grid2 right after after row l
00907 if (m) column = grid2->width-1;
00908 else column = 0;
00909 grid2 = R_GridInsertRow( grid2, l+1, column,
00910 grid1->verts[grid1->width * (k + 1) + offset1].xyz, grid1->heightLodError[k+1]);
00911 grid2->lodStitched = qfalse;
00912 s_worldData.surfaces[grid2num].data = (void *) grid2;
00913 return qtrue;
00914 }
00915 }
00916 }
00917 }
00918 for (n = 0; n < 2; n++) {
00919 //
00920 if (n) offset1 = (grid1->height-1) * grid1->width;
00921 else offset1 = 0;
00922 if (R_MergedWidthPoints(grid1, offset1))
00923 continue;
00924 for (k = grid1->width-1; k > 1; k -= 2) {
00925
00926 for (m = 0; m < 2; m++) {
00927
00928 if ( grid2->width >= MAX_GRID_SIZE )
00929 break;
00930 if (m) offset2 = (grid2->height-1) * grid2->width;
00931 else offset2 = 0;
00932 for ( l = 0; l < grid2->width-1; l++) {
00933 //
00934 v1 = grid1->verts[k + offset1].xyz;
00935 v2 = grid2->verts[l + offset2].xyz;
00936 if ( fabs(v1[0] - v2[0]) > .1)
00937 continue;
00938 if ( fabs(v1[1] - v2[1]) > .1)
00939 continue;
00940 if ( fabs(v1[2] - v2[2]) > .1)
00941 continue;
00942
00943 v1 = grid1->verts[k - 2 + offset1].xyz;
00944 v2 = grid2->verts[l + 1 + offset2].xyz;
00945 if ( fabs(v1[0] - v2[0]) > .1)
00946 continue;
00947 if ( fabs(v1[1] - v2[1]) > .1)
00948 continue;
00949 if ( fabs(v1[2] - v2[2]) > .1)
00950 continue;
00951 //
00952 v1 = grid2->verts[l + offset2].xyz;
00953 v2 = grid2->verts[(l + 1) + offset2].xyz;
00954 if ( fabs(v1[0] - v2[0]) < .01 &&
00955 fabs(v1[1] - v2[1]) < .01 &&
00956 fabs(v1[2] - v2[2]) < .01)
00957 continue;
00958 //
00959 //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" );
00960 // insert column into grid2 right after after column l
00961 if (m) row = grid2->height-1;
00962 else row = 0;
00963 grid2 = R_GridInsertColumn( grid2, l+1, row,
00964 grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]);
00965 grid2->lodStitched = qfalse;
00966 s_worldData.surfaces[grid2num].data = (void *) grid2;
00967 return qtrue;
00968 }
00969 }
00970 for (m = 0; m < 2; m++) {
00971
00972 if (grid2->height >= MAX_GRID_SIZE)
00973 break;
00974 if (m) offset2 = grid2->width-1;
00975 else offset2 = 0;
00976 for ( l = 0; l < grid2->height-1; l++) {
00977 //
00978 v1 = grid1->verts[k + offset1].xyz;
00979 v2 = grid2->verts[grid2->width * l + offset2].xyz;
00980 if ( fabs(v1[0] - v2[0]) > .1)
00981 continue;
00982 if ( fabs(v1[1] - v2[1]) > .1)
00983 continue;
00984 if ( fabs(v1[2] - v2[2]) > .1)
00985 continue;
00986
00987 v1 = grid1->verts[k - 2 + offset1].xyz;
00988 v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;
00989 if ( fabs(v1[0] - v2[0]) > .1)
00990 continue;
00991 if ( fabs(v1[1] - v2[1]) > .1)
00992 continue;
00993 if ( fabs(v1[2] - v2[2]) > .1)
00994 continue;
00995 //
00996 v1 = grid2->verts[grid2->width * l + offset2].xyz;
00997 v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;
00998 if ( fabs(v1[0] - v2[0]) < .01 &&
00999 fabs(v1[1] - v2[1]) < .01 &&
01000 fabs(v1[2] - v2[2]) < .01)
01001 continue;
01002 //
01003 //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" );
01004 // insert row into grid2 right after after row l
01005 if (m) column = grid2->width-1;
01006 else column = 0;
01007 grid2 = R_GridInsertRow( grid2, l+1, column,
01008 grid1->verts[k - 1 + offset1].xyz, grid1->widthLodError[k+1]);
01009 if (!grid2)
01010 break;
01011 grid2->lodStitched = qfalse;
01012 s_worldData.surfaces[grid2num].data = (void *) grid2;
01013 return qtrue;
01014 }
01015 }
01016 }
01017 }
01018 for (n = 0; n < 2; n++) {
01019 //
01020 if (n) offset1 = grid1->width-1;
01021 else offset1 = 0;
01022 if (R_MergedHeightPoints(grid1, offset1))
01023 continue;
01024 for (k = grid1->height-1; k > 1; k -= 2) {
01025 for (m = 0; m < 2; m++) {
01026
01027 if ( grid2->width >= MAX_GRID_SIZE )
01028 break;
01029 if (m) offset2 = (grid2->height-1) * grid2->width;
01030 else offset2 = 0;
01031 for ( l = 0; l < grid2->width-1; l++) {
01032 //
01033 v1 = grid1->verts[grid1->width * k + offset1].xyz;
01034 v2 = grid2->verts[l + offset2].xyz;
01035 if ( fabs(v1[0] - v2[0]) > .1)
01036 continue;
01037 if ( fabs(v1[1] - v2[1]) > .1)
01038 continue;
01039 if ( fabs(v1[2] - v2[2]) > .1)
01040 continue;
01041
01042 v1 = grid1->verts[grid1->width * (k - 2) + offset1].xyz;
01043 v2 = grid2->verts[l + 1 + offset2].xyz;
01044 if ( fabs(v1[0] - v2[0]) > .1)
01045 continue;
01046 if ( fabs(v1[1] - v2[1]) > .1)
01047 continue;
01048 if ( fabs(v1[2] - v2[2]) > .1)
01049 continue;
01050 //
01051 v1 = grid2->verts[l + offset2].xyz;
01052 v2 = grid2->verts[(l + 1) + offset2].xyz;
01053 if ( fabs(v1[0] - v2[0]) < .01 &&
01054 fabs(v1[1] - v2[1]) < .01 &&
01055 fabs(v1[2] - v2[2]) < .01)
01056 continue;
01057 //
01058 //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" );
01059 // insert column into grid2 right after after column l
01060 if (m) row = grid2->height-1;
01061 else row = 0;
01062 grid2 = R_GridInsertColumn( grid2, l+1, row,
01063 grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]);
01064 grid2->lodStitched = qfalse;
01065 s_worldData.surfaces[grid2num].data = (void *) grid2;
01066 return qtrue;
01067 }
01068 }
01069 for (m = 0; m < 2; m++) {
01070
01071 if (grid2->height >= MAX_GRID_SIZE)
01072 break;
01073 if (m) offset2 = grid2->width-1;
01074 else offset2 = 0;
01075 for ( l = 0; l < grid2->height-1; l++) {
01076 //
01077 v1 = grid1->verts[grid1->width * k + offset1].xyz;
01078 v2 = grid2->verts[grid2->width * l + offset2].xyz;
01079 if ( fabs(v1[0] - v2[0]) > .1)
01080 continue;
01081 if ( fabs(v1[1] - v2[1]) > .1)
01082 continue;
01083 if ( fabs(v1[2] - v2[2]) > .1)
01084 continue;
01085
01086 v1 = grid1->verts[grid1->width * (k - 2) + offset1].xyz;
01087 v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;
01088 if ( fabs(v1[0] - v2[0]) > .1)
01089 continue;
01090 if ( fabs(v1[1] - v2[1]) > .1)
01091 continue;
01092 if ( fabs(v1[2] - v2[2]) > .1)
01093 continue;
01094 //
01095 v1 = grid2->verts[grid2->width * l + offset2].xyz;
01096 v2 = grid2->verts[grid2->width * (l + 1) + offset2].xyz;
01097 if ( fabs(v1[0] - v2[0]) < .01 &&
01098 fabs(v1[1] - v2[1]) < .01 &&
01099 fabs(v1[2] - v2[2]) < .01)
01100 continue;
01101 //
01102 //ri.Printf( PRINT_ALL, "found highest LoD crack between two patches\n" );
01103 // insert row into grid2 right after after row l
01104 if (m) column = grid2->width-1;
01105 else column = 0;
01106 grid2 = R_GridInsertRow( grid2, l+1, column,
01107 grid1->verts[grid1->width * (k - 1) + offset1].xyz, grid1->heightLodError[k+1]);
01108 grid2->lodStitched = qfalse;
01109 s_worldData.surfaces[grid2num].data = (void *) grid2;
01110 return qtrue;
01111 }
01112 }
01113 }
01114 }
01115 return qfalse;
01116 }
|
Here is the call graph for this function:

|
|
Definition at line 1131 of file tr_bsp.c. References msurface_s::data, j, srfGridMesh_s::lodOrigin, srfGridMesh_s::lodRadius, world_t::numsurfaces, R_StitchPatches(), s_worldData, srfGridMesh_t, world_t::surfaces, and srfGridMesh_s::surfaceType. Referenced by R_StitchAllPatches(). 01131 {
01132 int j, numstitches;
01133 srfGridMesh_t *grid1, *grid2;
01134
01135 numstitches = 0;
01136 grid1 = (srfGridMesh_t *) s_worldData.surfaces[grid1num].data;
01137 for ( j = 0; j < s_worldData.numsurfaces; j++ ) {
01138 //
01139 grid2 = (srfGridMesh_t *) s_worldData.surfaces[j].data;
01140 // if this surface is not a grid
01141 if ( grid2->surfaceType != SF_GRID ) continue;
01142 // grids in the same LOD group should have the exact same lod radius
01143 if ( grid1->lodRadius != grid2->lodRadius ) continue;
01144 // grids in the same LOD group should have the exact same lod origin
01145 if ( grid1->lodOrigin[0] != grid2->lodOrigin[0] ) continue;
01146 if ( grid1->lodOrigin[1] != grid2->lodOrigin[1] ) continue;
01147 if ( grid1->lodOrigin[2] != grid2->lodOrigin[2] ) continue;
01148 //
01149 while (R_StitchPatches(grid1num, j))
01150 {
01151 numstitches++;
01152 }
01153 }
01154 return numstitches;
01155 }
|
Here is the call graph for this function:

|
|
Definition at line 1789 of file tr_bsp.c. References world_t::baseName, BSP_VERSION, buffer, byte, c_gridVerts, Com_Memset(), COM_SkipPath(), COM_StripExtension(), world_t::dataSize, ERR_DROP, fileBase, refimport_t::FS_FreeFile, refimport_t::FS_ReadFile, h_low, header, refimport_t::Hunk_Alloc, i, LittleLong(), LUMP_BRUSHES, LUMP_BRUSHSIDES, LUMP_DRAWINDEXES, LUMP_DRAWVERTS, LUMP_ENTITIES, LUMP_FOGS, LUMP_LEAFS, LUMP_LEAFSURFACES, LUMP_LIGHTGRID, LUMP_LIGHTMAPS, LUMP_MODELS, LUMP_NODES, LUMP_PLANES, LUMP_SHADERS, LUMP_SURFACES, LUMP_VISIBILITY, dheader_t::lumps, name, world_t::name, Q_strncpyz(), R_LoadEntities(), R_LoadFogs(), R_LoadLightGrid(), R_LoadLightmaps(), R_LoadMarksurfaces(), R_LoadNodesAndLeafs(), R_LoadPlanes(), R_LoadShaders(), R_LoadSubmodels(), R_LoadSurfaces(), R_LoadVisibility(), ri, s_worldData, trGlobals_t::sunDirection, tr, VectorNormalize(), dheader_t::version, trGlobals_t::world, and trGlobals_t::worldMapLoaded. 01789 {
01790 int i;
01791 dheader_t *header;
01792 byte *buffer;
01793 byte *startMarker;
01794
01795 if ( tr.worldMapLoaded ) {
01796 ri.Error( ERR_DROP, "ERROR: attempted to redundantly load world map\n" );
01797 }
01798
01799 // set default sun direction to be used if it isn't
01800 // overridden by a shader
01801 tr.sunDirection[0] = 0.45f;
01802 tr.sunDirection[1] = 0.3f;
01803 tr.sunDirection[2] = 0.9f;
01804
01805 VectorNormalize( tr.sunDirection );
01806
01807 tr.worldMapLoaded = qtrue;
01808
01809 // load it
01810 ri.FS_ReadFile( name, (void **)&buffer );
01811 if ( !buffer ) {
01812 ri.Error (ERR_DROP, "RE_LoadWorldMap: %s not found", name);
01813 }
01814
01815 // clear tr.world so if the level fails to load, the next
01816 // try will not look at the partially loaded version
01817 tr.world = NULL;
01818
01819 Com_Memset( &s_worldData, 0, sizeof( s_worldData ) );
01820 Q_strncpyz( s_worldData.name, name, sizeof( s_worldData.name ) );
01821
01822 Q_strncpyz( s_worldData.baseName, COM_SkipPath( s_worldData.name ), sizeof( s_worldData.name ) );
01823 COM_StripExtension( s_worldData.baseName, s_worldData.baseName );
01824
01825 startMarker = ri.Hunk_Alloc(0, h_low);
01826 c_gridVerts = 0;
01827
01828 header = (dheader_t *)buffer;
01829 fileBase = (byte *)header;
01830
01831 i = LittleLong (header->version);
01832 if ( i != BSP_VERSION ) {
01833 ri.Error (ERR_DROP, "RE_LoadWorldMap: %s has wrong version number (%i should be %i)",
01834 name, i, BSP_VERSION);
01835 }
01836
01837 // swap all the lumps
01838 for (i=0 ; i<sizeof(dheader_t)/4 ; i++) {
01839 ((int *)header)[i] = LittleLong ( ((int *)header)[i]);
01840 }
01841
01842 // load into heap
01843 R_LoadShaders( &header->lumps[LUMP_SHADERS] );
01844 R_LoadLightmaps( &header->lumps[LUMP_LIGHTMAPS] );
01845 R_LoadPlanes (&header->lumps[LUMP_PLANES]);
01846 R_LoadFogs( &header->lumps[LUMP_FOGS], &header->lumps[LUMP_BRUSHES], &header->lumps[LUMP_BRUSHSIDES] );
01847 R_LoadSurfaces( &header->lumps[LUMP_SURFACES], &header->lumps[LUMP_DRAWVERTS], &header->lumps[LUMP_DRAWINDEXES] );
01848 R_LoadMarksurfaces (&header->lumps[LUMP_LEAFSURFACES]);
01849 R_LoadNodesAndLeafs (&header->lumps[LUMP_NODES], &header->lumps[LUMP_LEAFS]);
01850 R_LoadSubmodels (&header->lumps[LUMP_MODELS]);
01851 R_LoadVisibility( &header->lumps[LUMP_VISIBILITY] );
01852 R_LoadEntities( &header->lumps[LUMP_ENTITIES] );
01853 R_LoadLightGrid( &header->lumps[LUMP_LIGHTGRID] );
01854
01855 s_worldData.dataSize = (byte *)ri.Hunk_Alloc(0, h_low) - startMarker;
01856
01857 // only set tr.world now that we know the entire level has loaded properly
01858 tr.world = &s_worldData;
01859
01860 ri.FS_FreeFile( buffer );
01861 }
|
Here is the call graph for this function:

|
|
Definition at line 222 of file tr_bsp.c. References byte, trGlobals_t::externalVisData, and tr. 00222 {
00223 tr.externalVisData = vis;
00224 }
|
|
||||||||||||
|
Definition at line 270 of file tr_bsp.c. References trGlobals_t::defaultShader, shader_s::defaultShader, ERR_DROP, glConfig, glconfig_t::hardwareType, cvar_s::integer, LittleLong(), world_t::numShaders, qtrue, R_FindShader(), r_fullbright, r_vertexLight, ri, s_worldData, dshader_t::shader, shader_t, world_t::shaders, and tr. Referenced by ParseFace(), ParseFlare(), ParseMesh(), and ParseTriSurf(). 00270 {
00271 shader_t *shader;
00272 dshader_t *dsh;
00273
00274 shaderNum = LittleLong( shaderNum );
00275 if ( shaderNum < 0 || shaderNum >= s_worldData.numShaders ) {
00276 ri.Error( ERR_DROP, "ShaderForShaderNum: bad num %i", shaderNum );
00277 }
00278 dsh = &s_worldData.shaders[ shaderNum ];
00279
00280 if ( r_vertexLight->integer || glConfig.hardwareType == GLHW_PERMEDIA2 ) {
00281 lightmapNum = LIGHTMAP_BY_VERTEX;
00282 }
00283
00284 if ( r_fullbright->integer ) {
00285 lightmapNum = LIGHTMAP_WHITEIMAGE;
00286 }
00287
00288 shader = R_FindShader( dsh->shader, lightmapNum, qtrue );
00289
00290 // if the shader had errors, just use default shader
00291 if ( shader->defaultShader ) {
00292 return tr.defaultShader;
00293 }
00294
00295 return shader;
00296 }
|
Here is the call graph for this function:

|
|
Definition at line 40 of file tr_bsp.c. Referenced by RE_LoadWorldMap(). |
|
|
|
|
|
Definition at line 37 of file tr_bsp.c. Referenced by R_LoadEntities(), R_LoadFogs(), R_LoadLightGrid(), R_LoadLightmaps(), R_LoadMarksurfaces(), R_LoadNodesAndLeafs(), R_LoadPlanes(), R_LoadShaders(), R_LoadSubmodels(), R_LoadSurfaces(), R_LoadVisibility(), and RE_LoadWorldMap(). |
|
1.3.9.1