#include "qbsp.h"
Include dependency graph for bsp.c:

Go to the source code of this file.
Functions | |
| void | Bspinfo (int count, char **fileNames) |
| int | LightMain (int argc, char **argv) |
| int | main (int argc, char **argv) |
| void | OnlyEnts (void) |
| void | OnlyTextures (void) |
| void | ProcessModels (void) |
| void | ProcessSubModel (void) |
| void | ProcessWorldModel (void) |
| int | VisMain (int argc, char **argv) |
| int | VLightMain (int argc, char **argv) |
| int | VSoundMain (int argc, char **argv) |
Variables | |
| int | entity_num |
| qboolean | fakemap |
| qboolean | fulldetail |
| qboolean | glview |
| qboolean | leaktest |
| vec_t | microvolume = 1.0 |
| char | name [1024] |
| qboolean | noCurveBrushes |
| qboolean | nodetail |
| qboolean | nofill |
| qboolean | nofog |
| qboolean | nomerge |
| qboolean | noopt |
| qboolean | nosubdivide |
| qboolean | notjunc |
| qboolean | nowater |
| qboolean | onlyents |
| qboolean | onlytextures |
| char | outbase [32] |
| qboolean | showseams |
| char | source [1024] |
| char | tempsource [1024] |
| qboolean | testExpand |
| qboolean | verboseentities |
|
||||||||||||
|
Definition at line 273 of file bsp.c. References _printf(), count, DefaultExtension(), f, fclose(), fopen(), i, LoadBSPFile(), PrintBSPFileSizes(), Q_filelength(), source, and strcpy(). Referenced by main(). 00273 {
00274 int i;
00275 char source[1024];
00276 int size;
00277 FILE *f;
00278
00279 if ( count < 1 ) {
00280 _printf( "No files to dump info for.\n");
00281 return;
00282 }
00283
00284 for ( i = 0 ; i < count ; i++ ) {
00285 _printf ("---------------------\n");
00286 strcpy (source, fileNames[ i ] );
00287 DefaultExtension (source, ".bsp");
00288 f = fopen (source, "rb");
00289 if (f)
00290 {
00291 size = Q_filelength (f);
00292 fclose (f);
00293 }
00294 else
00295 size = 0;
00296 _printf ("%s: %i\n", source, size);
00297
00298 LoadBSPFile (source);
00299 PrintBSPFileSizes ();
00300 _printf ("---------------------\n");
00301 }
00302 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 2018 of file light.c. References _printf(), areaScale, argc, argv, atof(), atoi, CountLightmaps(), CreateFilters(), CreateSurfaceLights(), DefaultExtension(), dump, entities, exit(), ExpandArg(), extra, extraWide, FindSkyBrushes(), gamedir, gridSize, i, I_FloatTime(), InitPakFile(), InitTrace(), lightmapBorder, LightWorld(), LoadBSPFile(), LoadShaderInfo(), nogridlighting, noSurfaces, notrace, novertexlighting, NULL, numthreads, ParseEntities(), patchshadows, pointScale, samplesize, SetEntityOrigins(), SetQdirFromPath(), source, sscanf(), strcmp(), strcpy(), StripExtension(), strlen(), ThreadSetDefault(), value, ValueForKey(), verbose, and WriteBSPFile(). Referenced by main(). 02018 {
02019 int i;
02020 double start, end;
02021 const char *value;
02022
02023 _printf ("----- Lighting ----\n");
02024
02025 verbose = qfalse;
02026
02027 for (i=1 ; i<argc ; i++) {
02028 if (!strcmp(argv[i],"-tempname"))
02029 {
02030 i++;
02031 } else if (!strcmp(argv[i],"-v")) {
02032 verbose = qtrue;
02033 } else if (!strcmp(argv[i],"-threads")) {
02034 numthreads = atoi (argv[i+1]);
02035 i++;
02036 } else if (!strcmp(argv[i],"-area")) {
02037 areaScale *= atof(argv[i+1]);
02038 _printf ("area light scaling at %f\n", areaScale);
02039 i++;
02040 } else if (!strcmp(argv[i],"-point")) {
02041 pointScale *= atof(argv[i+1]);
02042 _printf ("point light scaling at %f\n", pointScale);
02043 i++;
02044 } else if (!strcmp(argv[i],"-notrace")) {
02045 notrace = qtrue;
02046 _printf ("No occlusion tracing\n");
02047 } else if (!strcmp(argv[i],"-patchshadows")) {
02048 patchshadows = qtrue;
02049 _printf ("Patch shadow casting enabled\n");
02050 } else if (!strcmp(argv[i],"-extra")) {
02051 extra = qtrue;
02052 _printf ("Extra detail tracing\n");
02053 } else if (!strcmp(argv[i],"-extrawide")) {
02054 extra = qtrue;
02055 extraWide = qtrue;
02056 _printf ("Extra wide detail tracing\n");
02057 } else if (!strcmp(argv[i], "-samplesize")) {
02058 samplesize = atoi(argv[i+1]);
02059 if (samplesize < 1) samplesize = 1;
02060 i++;
02061 _printf("lightmap sample size is %dx%d units\n", samplesize, samplesize);
02062 } else if (!strcmp(argv[i], "-novertex")) {
02063 novertexlighting = qtrue;
02064 _printf("no vertex lighting = true\n");
02065 } else if (!strcmp(argv[i], "-nogrid")) {
02066 nogridlighting = qtrue;
02067 _printf("no grid lighting = true\n");
02068 } else if (!strcmp(argv[i],"-border")) {
02069 lightmapBorder = qtrue;
02070 _printf ("Adding debug border to lightmaps\n");
02071 } else if (!strcmp(argv[i],"-nosurf")) {
02072 noSurfaces = qtrue;
02073 _printf ("Not tracing against surfaces\n" );
02074 } else if (!strcmp(argv[i],"-dump")) {
02075 dump = qtrue;
02076 _printf ("Dumping occlusion maps\n");
02077 } else {
02078 break;
02079 }
02080 }
02081
02082 ThreadSetDefault ();
02083
02084 if (i != argc - 1) {
02085 _printf("usage: q3map -light [-<switch> [-<switch> ...]] <mapname>\n"
02086 "\n"
02087 "Switches:\n"
02088 " v = verbose output\n"
02089 " threads <X> = set number of threads to X\n"
02090 " area <V> = set the area light scale to V\n"
02091 " point <W> = set the point light scale to W\n"
02092 " notrace = don't cast any shadows\n"
02093 " extra = enable super sampling for anti-aliasing\n"
02094 " extrawide = same as extra but smoothen more\n"
02095 " nogrid = don't calculate light grid for dynamic model lighting\n"
02096 " novertex = don't calculate vertex lighting\n"
02097 " samplesize <N> = set the lightmap pixel size to NxN units\n");
02098 exit(0);
02099 }
02100
02101 start = I_FloatTime ();
02102
02103 SetQdirFromPath (argv[i]);
02104
02105 #ifdef _WIN32
02106 InitPakFile(gamedir, NULL);
02107 #endif
02108
02109 strcpy (source, ExpandArg(argv[i]));
02110 StripExtension (source);
02111 DefaultExtension (source, ".bsp");
02112
02113 LoadShaderInfo();
02114
02115 _printf ("reading %s\n", source);
02116
02117 LoadBSPFile (source);
02118
02119 FindSkyBrushes();
02120
02121 ParseEntities();
02122
02123 value = ValueForKey( &entities[0], "gridsize" );
02124 if (strlen(value)) {
02125 sscanf( value, "%f %f %f", &gridSize[0], &gridSize[1], &gridSize[2] );
02126 _printf("grid size = {%1.1f, %1.1f, %1.1f}\n", gridSize[0], gridSize[1], gridSize[2]);
02127 }
02128
02129 CreateFilters();
02130
02131 InitTrace();
02132
02133 SetEntityOrigins();
02134
02135 CountLightmaps();
02136
02137 CreateSurfaceLights();
02138
02139 LightWorld();
02140
02141 _printf ("writing %s\n", source);
02142 WriteBSPFile (source);
02143
02144 end = I_FloatTime ();
02145 _printf ("%5.0f seconds elapsed\n", end-start);
02146
02147 return 0;
02148 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 362 of file bsp.c. References _printf(), argc, argv, atof(), atoi, Bspinfo(), DefaultExtension(), drawflag, EndBSPFile(), Error(), ExpandArg(), fakemap, fulldetail, gamedir, glview, i, I_FloatTime(), InitPakFile(), leaktest, LightMain(), LoadMapFile(), LoadShaderInfo(), microvolume, name, noCurveBrushes, nodetail, nofill, nofog, noopt, nosubdivide, notjunc, nowater, NULL, numthreads, OnlyEnts(), onlyents, OnlyTextures(), onlytextures, outbase, ProcessModels(), remove(), samplesize, SetLightStyles(), SetModelNumbers(), SetQdirFromPath(), showseams, source, sprintf(), strcmp(), strcpy(), StripExtension(), strlen(), tempsource, testExpand, ThreadSetDefault(), verbose, verboseentities, VisMain(), VLightMain(), and VSoundMain(). 00362 {
00363 int i;
00364 double start, end;
00365 char path[1024];
00366
00367 _printf ("Q3Map v1.0s (c) 1999 Id Software Inc.\n");
00368
00369 if ( argc < 2 ) {
00370 Error ("usage: q3map [options] mapfile");
00371 }
00372
00373 // check for general program options
00374 if (!strcmp(argv[1], "-info")) {
00375 Bspinfo( argc - 2, argv + 2 );
00376 return 0;
00377 }
00378 if (!strcmp(argv[1], "-light")) {
00379 LightMain( argc - 1, argv + 1 );
00380 return 0;
00381 }
00382 if (!strcmp(argv[1], "-vlight")) {
00383 VLightMain( argc - 1, argv + 1 );
00384 return 0;
00385 }
00386 if (!strcmp(argv[1], "-vsound")) {
00387 VSoundMain( argc - 1, argv + 1 );
00388 return 0;
00389 }
00390 if (!strcmp(argv[1], "-vis")) {
00391 VisMain( argc - 1, argv + 1 );
00392 return 0;
00393 }
00394
00395 // do a bsp if nothing else was specified
00396
00397 _printf ("---- q3map ----\n");
00398
00399 tempsource[0] = '\0';
00400
00401 for (i=1 ; i<argc ; i++)
00402 {
00403 if (!strcmp(argv[i],"-tempname"))
00404 {
00405 strcpy(tempsource, argv[++i]);
00406 }
00407 else if (!strcmp(argv[i],"-threads"))
00408 {
00409 numthreads = atoi (argv[i+1]);
00410 i++;
00411 }
00412 else if (!strcmp(argv[i],"-glview"))
00413 {
00414 glview = qtrue;
00415 }
00416 else if (!strcmp(argv[i], "-v"))
00417 {
00418 _printf ("verbose = true\n");
00419 verbose = qtrue;
00420 }
00421 else if (!strcmp(argv[i], "-draw"))
00422 {
00423 _printf ("drawflag = true\n");
00424 drawflag = qtrue;
00425 }
00426 else if (!strcmp(argv[i], "-nowater"))
00427 {
00428 _printf ("nowater = true\n");
00429 nowater = qtrue;
00430 }
00431 else if (!strcmp(argv[i], "-noopt"))
00432 {
00433 _printf ("noopt = true\n");
00434 noopt = qtrue;
00435 }
00436 else if (!strcmp(argv[i], "-nofill"))
00437 {
00438 _printf ("nofill = true\n");
00439 nofill = qtrue;
00440 }
00441 else if (!strcmp(argv[i], "-nodetail"))
00442 {
00443 _printf ("nodetail = true\n");
00444 nodetail = qtrue;
00445 }
00446 else if (!strcmp(argv[i], "-fulldetail"))
00447 {
00448 _printf ("fulldetail = true\n");
00449 fulldetail = qtrue;
00450 }
00451 else if (!strcmp(argv[i], "-onlyents"))
00452 {
00453 _printf ("onlyents = true\n");
00454 onlyents = qtrue;
00455 }
00456 else if (!strcmp(argv[i], "-onlytextures"))
00457 {
00458 _printf ("onlytextures = true\n"); // FIXME: make work again!
00459 onlytextures = qtrue;
00460 }
00461 else if (!strcmp(argv[i], "-micro"))
00462 {
00463 microvolume = atof(argv[i+1]);
00464 _printf ("microvolume = %f\n", microvolume);
00465 i++;
00466 }
00467 else if (!strcmp(argv[i], "-nofog"))
00468 {
00469 _printf ("nofog = true\n");
00470 nofog = qtrue;
00471 }
00472 else if (!strcmp(argv[i], "-nosubdivide"))
00473 {
00474 _printf ("nosubdivide = true\n");
00475 nosubdivide = qtrue;
00476 }
00477 else if (!strcmp(argv[i], "-leaktest"))
00478 {
00479 _printf ("leaktest = true\n");
00480 leaktest = qtrue;
00481 }
00482 else if (!strcmp(argv[i], "-verboseentities"))
00483 {
00484 _printf ("verboseentities = true\n");
00485 verboseentities = qtrue;
00486 }
00487 else if (!strcmp(argv[i], "-nocurves"))
00488 {
00489 noCurveBrushes = qtrue;
00490 _printf ("no curve brushes\n");
00491 }
00492 else if (!strcmp(argv[i], "-notjunc"))
00493 {
00494 notjunc = qtrue;
00495 _printf ("no tjunction fixing\n");
00496 }
00497 else if (!strcmp(argv[i], "-expand"))
00498 {
00499 testExpand = qtrue;
00500 _printf ("Writing expanded.map.\n");
00501 }
00502 else if (!strcmp(argv[i], "-showseams"))
00503 {
00504 showseams = qtrue;
00505 _printf ("Showing seams on terrain.\n");
00506 }
00507 else if (!strcmp (argv[i],"-tmpout"))
00508 {
00509 strcpy (outbase, "/tmp");
00510 }
00511 else if (!strcmp (argv[i],"-fakemap"))
00512 {
00513 fakemap = qtrue;
00514 _printf( "will generate fakemap.map\n");
00515 }
00516 else if (!strcmp(argv[i], "-samplesize"))
00517 {
00518 samplesize = atoi(argv[i+1]);
00519 if (samplesize < 1) samplesize = 1;
00520 i++;
00521 _printf("lightmap sample size is %dx%d units\n", samplesize, samplesize);
00522 }
00523 else if (argv[i][0] == '-')
00524 Error ("Unknown option \"%s\"", argv[i]);
00525 else
00526 break;
00527 }
00528
00529 if (i != argc - 1)
00530 Error ("usage: q3map [options] mapfile");
00531
00532 start = I_FloatTime ();
00533
00534 ThreadSetDefault ();
00535 //numthreads = 1; // multiple threads aren't helping because of heavy malloc use
00536 SetQdirFromPath (argv[i]);
00537
00538 #ifdef _WIN32
00539 InitPakFile(gamedir, NULL);
00540 #endif
00541
00542 strcpy (source, ExpandArg (argv[i]));
00543 StripExtension (source);
00544
00545 // delete portal and line files
00546 sprintf (path, "%s.prt", source);
00547 remove (path);
00548 sprintf (path, "%s.lin", source);
00549 remove (path);
00550
00551 strcpy (name, ExpandArg (argv[i]));
00552 if ( strcmp(name + strlen(name) - 4, ".reg" ) ) {
00553 // if we are doing a full map, delete the last saved region map
00554 sprintf (path, "%s.reg", source);
00555 remove (path);
00556
00557 DefaultExtension (name, ".map"); // might be .reg
00558 }
00559
00560 //
00561 // if onlyents, just grab the entites and resave
00562 //
00563 if ( onlyents ) {
00564 OnlyEnts();
00565 return 0;
00566 }
00567
00568 //
00569 // if onlytextures, just grab the textures and resave
00570 //
00571 if ( onlytextures ) {
00572 OnlyTextures();
00573 return 0;
00574 }
00575
00576 //
00577 // start from scratch
00578 //
00579 LoadShaderInfo();
00580
00581 // load original file from temp spot in case it was renamed by the editor on the way in
00582 if (strlen(tempsource) > 0) {
00583 LoadMapFile (tempsource);
00584 } else {
00585 LoadMapFile (name);
00586 }
00587
00588 SetModelNumbers ();
00589 SetLightStyles ();
00590
00591 ProcessModels ();
00592
00593 EndBSPFile();
00594
00595 end = I_FloatTime ();
00596 _printf ("%5.0f seconds elapsed\n", end-start);
00597
00598 // remove temp name if appropriate
00599 if (strlen(tempsource) > 0) {
00600 remove(tempsource);
00601 }
00602
00603 return 0;
00604 }
|
Here is the call graph for this function:

|
|
Definition at line 310 of file bsp.c. References LoadBSPFile(), LoadMapFile(), name, num_entities, SetLightStyles(), SetModelNumbers(), source, sprintf(), UnparseEntities(), and WriteBSPFile(). Referenced by main(). 00310 {
00311 char out[1024];
00312
00313 sprintf (out, "%s.bsp", source);
00314 LoadBSPFile (out);
00315 num_entities = 0;
00316
00317 LoadMapFile (name);
00318 SetModelNumbers ();
00319 SetLightStyles ();
00320
00321 UnparseEntities ();
00322
00323 WriteBSPFile (out);
00324 }
|
Here is the call graph for this function:

|
|
Definition at line 332 of file bsp.c. References Error(), i, LoadBSPFile(), LoadMapFile(), name, source, sprintf(), and WriteBSPFile(). Referenced by main(). 00332 { // FIXME!!!
00333 char out[1024];
00334 int i;
00335
00336 Error( "-onlytextures isn't working now..." );
00337
00338 sprintf (out, "%s.bsp", source);
00339
00340 LoadMapFile (name);
00341
00342 LoadBSPFile (out);
00343
00344 // replace all the drawsurface shader names
00345 for ( i = 0 ; i < numDrawSurfaces ; i++ ) {
00346 }
00347
00348 WriteBSPFile (out);
00349 }
|
Here is the call graph for this function:

|
|
Definition at line 239 of file bsp.c. References BeginBSPFile(), entity_t::brushes, entities, entity_num, nummodels, entity_t::patches, ProcessSubModel(), ProcessWorldModel(), qboolean, qprintf(), and verbose. Referenced by main(). 00240 {
00241 qboolean oldVerbose;
00242 entity_t *entity;
00243
00244 oldVerbose = verbose;
00245
00246 BeginBSPFile ();
00247
00248 for ( entity_num=0 ; entity_num< num_entities ; entity_num++ ) {
00249 entity = &entities[entity_num];
00250
00251 if ( !entity->brushes && !entity->patches ) {
00252 continue;
00253 }
00254
00255 qprintf ("############### model %i ###############\n", nummodels);
00256 if (entity_num == 0)
00257 ProcessWorldModel ();
00258 else
00259 ProcessSubModel ();
00260
00261 if (!verboseentities)
00262 verbose = qfalse; // don't bother printing submodels
00263 }
00264
00265 verbose = oldVerbose;
00266 }
|
Here is the call graph for this function:

|
|
Definition at line 178 of file bsp.c. References AllocateLightmaps(), AllocNode(), AllocTree(), b, BeginModel(), entity_t::brushes, node_s::brushlist, bspbrush_t, ClipSidesIntoTree(), CopyBrush(), e, EndModel(), entities, FilterDrawsurfsIntoTree(), entity_t::firstDrawSurf, FixTJunctions(), FreeTree(), MergeSides(), bspbrush_s::next, node_t, PatchMapDrawSurfs(), node_s::planenum, SubdivideDrawSurfs(), and tree(). Referenced by ProcessModels(). 00178 {
00179 entity_t *e;
00180 tree_t *tree;
00181 bspbrush_t *b, *bc;
00182 node_t *node;
00183
00184 BeginModel ();
00185
00186 e = &entities[entity_num];
00187 e->firstDrawSurf = numMapDrawSurfs;
00188
00189 PatchMapDrawSurfs( e );
00190
00191 // just put all the brushes in an empty leaf
00192 // FIXME: patches?
00193 node = AllocNode();
00194 node->planenum = PLANENUM_LEAF;
00195 for ( b = e->brushes ; b ; b = b->next ) {
00196 bc = CopyBrush( b );
00197 bc->next = node->brushlist;
00198 node->brushlist = bc;
00199 }
00200
00201 tree = AllocTree();
00202 tree->headnode = node;
00203
00204 ClipSidesIntoTree( e, tree );
00205
00206 // subdivide each drawsurf as required by shader tesselation or fog
00207 if ( !nosubdivide ) {
00208 SubdivideDrawSurfs( e, tree );
00209 }
00210
00211 // merge together all common shaders on the same plane and remove
00212 // all colinear points, so extra tjunctions won't be generated
00213 if ( !nomerge ) {
00214 MergeSides( e, tree ); // !@# testing
00215 }
00216
00217 // add in any vertexes required to fix tjunctions
00218 if ( !notjunc ) {
00219 FixTJunctions( e );
00220 }
00221
00222 // allocate lightmaps for faces and patches
00223 AllocateLightmaps( e );
00224
00225 // add references to the final drawsurfs in the apropriate clusters
00226 FilterDrawsurfsIntoTree( e, tree );
00227
00228 EndModel ( node );
00229
00230 FreeTree( tree );
00231 }
|
Here is the call graph for this function:

|
|
Definition at line 67 of file bsp.c. References _printf(), AddTriangleModels(), AllocateLightmaps(), BeginModel(), bspface_t, ClipSidesIntoTree(), e, EndModel(), entities, exit(), FaceBSP(), faces, FillOutside(), FilterDetailBrushesIntoTree(), FilterDrawsurfsIntoTree(), FilterStructuralBrushesIntoTree(), entity_t::firstDrawSurf, FixTJunctions(), FloodAreas(), FloodEntities(), FogDrawSurfs(), FreeTree(), LeakFile(), MakeStructuralBspFaceList(), MakeTreePortals(), MakeVisibleBspFaceList(), MergeSides(), NumberClusters(), PatchMapDrawSurfs(), qboolean, source, SubdivideDrawSurfs(), tree(), WriteGLView(), and WritePortalFile(). Referenced by ProcessModels(). 00067 {
00068 entity_t *e;
00069 tree_t *tree;
00070 bspface_t *faces;
00071 qboolean leaked;
00072
00073 BeginModel();
00074
00075 e = &entities[0];
00076 e->firstDrawSurf = 0;//numMapDrawSurfs;
00077
00078 // check for patches with adjacent edges that need to LOD together
00079 PatchMapDrawSurfs( e );
00080
00081 // build an initial bsp tree using all of the sides
00082 // of all of the structural brushes
00083 faces = MakeStructuralBspFaceList ( entities[0].brushes );
00084 tree = FaceBSP( faces );
00085 MakeTreePortals (tree);
00086 FilterStructuralBrushesIntoTree( e, tree );
00087
00088 // see if the bsp is completely enclosed
00089 if ( FloodEntities (tree) ) {
00090 // rebuild a better bsp tree using only the
00091 // sides that are visible from the inside
00092 FillOutside (tree->headnode);
00093
00094 // chop the sides to the convex hull of
00095 // their visible fragments, giving us the smallest
00096 // polygons
00097 ClipSidesIntoTree( e, tree );
00098
00099 faces = MakeVisibleBspFaceList( entities[0].brushes );
00100 FreeTree (tree);
00101 tree = FaceBSP( faces );
00102 MakeTreePortals( tree );
00103 FilterStructuralBrushesIntoTree( e, tree );
00104 leaked = qfalse;
00105 } else {
00106 _printf ("**********************\n");
00107 _printf ("******* leaked *******\n");
00108 _printf ("**********************\n");
00109 LeakFile (tree);
00110 if ( leaktest ) {
00111 _printf ("--- MAP LEAKED, ABORTING LEAKTEST ---\n");
00112 exit (0);
00113 }
00114 leaked = qtrue;
00115
00116 // chop the sides to the convex hull of
00117 // their visible fragments, giving us the smallest
00118 // polygons
00119 ClipSidesIntoTree( e, tree );
00120 }
00121
00122 // save out information for visibility processing
00123 NumberClusters( tree );
00124 if ( !leaked ) {
00125 WritePortalFile( tree );
00126 }
00127 if ( glview ) {
00128 // dump the portals for debugging
00129 WriteGLView( tree, source );
00130 }
00131 FloodAreas (tree);
00132
00133 // add references to the detail brushes
00134 FilterDetailBrushesIntoTree( e, tree );
00135
00136 // create drawsurfs for triangle models
00137 AddTriangleModels( tree );
00138
00139 // drawsurfs that cross fog boundaries will need to
00140 // be split along the bound
00141 if ( !nofog ) {
00142 FogDrawSurfs(); // may fragment drawsurfs
00143 }
00144
00145 // subdivide each drawsurf as required by shader tesselation
00146 if ( !nosubdivide ) {
00147 SubdivideDrawSurfs( e, tree );
00148 }
00149
00150 // merge together all common shaders on the same plane and remove
00151 // all colinear points, so extra tjunctions won't be generated
00152 if ( !nomerge ) {
00153 MergeSides( e, tree ); // !@# testing
00154 }
00155
00156 // add in any vertexes required to fix tjunctions
00157 if ( !notjunc ) {
00158 FixTJunctions( e );
00159 }
00160
00161 // allocate lightmaps for faces and patches
00162 AllocateLightmaps( e );
00163
00164 // add references to the final drawsurfs in the apropriate clusters
00165 FilterDrawsurfsIntoTree( e, tree );
00166
00167 EndModel( tree->headnode );
00168
00169 FreeTree (tree);
00170 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 1080 of file vis.c. References _printf(), argc, argv, atoi, CalcVis(), clock(), CountActivePortals(), Error(), ExpandArg(), fastvis, gamedir, i, I_FloatTime(), inbase, InitPakFile(), LoadBSPFile(), LoadPortals(), MergeLeafPortals(), MergeLeaves(), mergevis, name, noPassageVis, nosort, NULL, numthreads, numVisBytes, outbase, passageVisOnly, remove(), saveprt, SetQdirFromPath(), sprintf(), strcat(), strcmp(), strcpy(), StripExtension(), testlevel, ThreadSetDefault(), verbose, and WriteBSPFile(). Referenced by main(). 01081 {
01082 char portalfile[1024];
01083 char name[1024];
01084 int i;
01085 double start, end;
01086
01087 _printf ("---- vis ----\n");
01088
01089 verbose = qfalse;
01090 for (i=1 ; i<argc ; i++) {
01091 if (!strcmp(argv[i],"-threads")) {
01092 numthreads = atoi (argv[i+1]);
01093 i++;
01094 } else if (!strcmp(argv[i],"-threads")) {
01095 numthreads = atoi (argv[i+1]);
01096 i++;
01097 } else if (!strcmp(argv[i], "-fast")) {
01098 _printf ("fastvis = true\n");
01099 fastvis = qtrue;
01100 } else if (!strcmp(argv[i], "-merge")) {
01101 _printf ("merge = true\n");
01102 mergevis = qtrue;
01103 } else if (!strcmp(argv[i], "-nopassage")) {
01104 _printf ("nopassage = true\n");
01105 noPassageVis = qtrue;
01106 } else if (!strcmp(argv[i], "-passageOnly")) {
01107 _printf("passageOnly = true\n");
01108 passageVisOnly = qtrue;
01109 } else if (!strcmp(argv[i], "-level")) {
01110 testlevel = atoi(argv[i+1]);
01111 _printf ("testlevel = %i\n", testlevel);
01112 i++;
01113 } else if (!strcmp(argv[i], "-v")) {
01114 _printf ("verbose = true\n");
01115 verbose = qtrue;
01116 } else if (!strcmp (argv[i],"-nosort")) {
01117 _printf ("nosort = true\n");
01118 nosort = qtrue;
01119 } else if (!strcmp (argv[i],"-saveprt")) {
01120 _printf ("saveprt = true\n");
01121 saveprt = qtrue;
01122 } else if (!strcmp (argv[i],"-tmpin")) {
01123 strcpy (inbase, "/tmp");
01124 } else if (!strcmp (argv[i],"-tmpout")) {
01125 strcpy (outbase, "/tmp");
01126 } else if (argv[i][0] == '-') {
01127 Error ("Unknown option \"%s\"", argv[i]);
01128 } else {
01129 break;
01130 }
01131 }
01132
01133 if (i != argc - 1)
01134 Error ("usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile");
01135
01136 #ifdef MREDEBUG
01137 start = clock();
01138 #else
01139 start = I_FloatTime ();
01140 #endif
01141
01142 ThreadSetDefault ();
01143
01144 SetQdirFromPath (argv[i]);
01145
01146 #ifdef _WIN32
01147 InitPakFile(gamedir, NULL);
01148 #endif
01149
01150 // load the bsp
01151 sprintf (name, "%s%s", inbase, ExpandArg(argv[i]));
01152 StripExtension (name);
01153 strcat (name, ".bsp");
01154 _printf ("reading %s\n", name);
01155 LoadBSPFile (name);
01156
01157 // load the portal file
01158 sprintf (portalfile, "%s%s", inbase, ExpandArg(argv[i]));
01159 StripExtension (portalfile);
01160 strcat (portalfile, ".prt");
01161 _printf ("reading %s\n", portalfile);
01162 LoadPortals (portalfile);
01163
01164 if (mergevis)
01165 {
01166 MergeLeaves();
01167 MergeLeafPortals();
01168 }
01169
01170 CountActivePortals();
01171 // WritePortals("maps/hints.prs");
01172
01173 _printf ("visdatasize:%i\n", numVisBytes);
01174
01175 CalcVis ();
01176
01177 // CalcPHS ();
01178
01179 // delete the prt file
01180 if ( !saveprt ) {
01181 remove( portalfile );
01182 }
01183
01184 // write the bsp file
01185 _printf ("writing %s\n", name);
01186 WriteBSPFile (name);
01187
01188 #ifdef MREDEBUG
01189 end = clock();
01190 _printf ("%5.2f seconds elapsed\n", (end-start) / CLK_TCK);
01191 #else
01192 end = I_FloatTime ();
01193 _printf ("%5.2f seconds elapsed\n", end-start);
01194 #endif
01195 return 0;
01196 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 5594 of file lightv.c. References _printf(), argc, argv, atof(), atoi, clock(), CountLightmaps(), DefaultExtension(), defaulttracelight, entities, exit(), ExpandArg(), gamedir, GridAndVertexLighting(), gridSize, i, InitPakFile(), lightAreaScale, lightFloats, lightPointScale, LoadBSPFile(), LoadShaderInfo(), malloc(), memset(), noalphashading, nobackfaceculling, nocolorshading, nogridlighting, nostitching, novertexlighting, NULL, numLightBytes, numthreads, numvlights, ParseEntities(), radiosity, samplesize, SetEntityOrigins(), SetQdirFromPath(), source, sscanf(), strcmp(), strcpy(), StripExtension(), strlen(), ThreadSetDefault(), value, ValueForKey(), verbose, VL_CalcVisibleLightmapPixelArea(), VL_CreateEntityLights(), VL_CreateFakeSurfaceLights(), VL_CreateSkyLights(), VL_InitSurfacesForTesting(), VL_LightWorld(), VL_LoadPortals(), VL_TestLightLeafs(), and WriteBSPFile(). Referenced by main(). 05594 {
05595 int i;
05596 double start, end;
05597 const char *value;
05598
05599 _printf ("----- VLighting ----\n");
05600
05601 for (i=1 ; i<argc ; i++) {
05602 if (!strcmp(argv[i],"-v")) {
05603 verbose = qtrue;
05604 } else if (!strcmp(argv[i],"-threads")) {
05605 numthreads = atoi (argv[i+1]);
05606 _printf("num threads = %d\n", numthreads);
05607 i++;
05608 } else if (!strcmp(argv[i],"-area")) {
05609 lightAreaScale *= atof(argv[i+1]);
05610 _printf ("area light scaling at %f\n", lightAreaScale);
05611 i++;
05612 } else if (!strcmp(argv[i],"-point")) {
05613 lightPointScale *= atof(argv[i+1]);
05614 _printf ("point light scaling at %f\n", lightPointScale);
05615 i++;
05616 } else if (!strcmp(argv[i], "-samplesize")) {
05617 samplesize = atoi(argv[i+1]);
05618 if (samplesize < 1) samplesize = 1;
05619 i++;
05620 _printf("lightmap sample size is %dx%d units\n", samplesize, samplesize);
05621 } else if (!strcmp(argv[i], "-novertex")) {
05622 novertexlighting = qtrue;
05623 _printf("no vertex lighting = true\n");
05624 } else if (!strcmp(argv[i], "-nogrid")) {
05625 nogridlighting = qtrue;
05626 _printf("no grid lighting = true\n");
05627 } else if (!strcmp(argv[i], "-nostitching")) {
05628 nostitching = qtrue;
05629 _printf("no stitching = true\n");
05630 } else if (!strcmp(argv[i], "-noalphashading")) {
05631 noalphashading = qtrue;
05632 _printf("no alpha shading = true\n");
05633 } else if (!strcmp(argv[i], "-nocolorshading")) {
05634 nocolorshading = qtrue;
05635 _printf("old style alpha shading = true\n");
05636 } else if (!strcmp(argv[i], "-nobackfaceculling")) {
05637 nobackfaceculling = qtrue;
05638 _printf("no backface culling = true\n");
05639 } else if (!strcmp(argv[i], "-tracelight")) {
05640 defaulttracelight = qtrue;
05641 _printf("default trace light = true\n");
05642 } else if (!strcmp(argv[i], "-radiosity")) {
05643 radiosity = atoi(argv[i+1]);
05644 _printf("radiosity = %d\n", radiosity);
05645 i++;
05646 } else {
05647 break;
05648 }
05649 }
05650
05651 ThreadSetDefault ();
05652
05653 if (i != argc - 1) {
05654 _printf("usage: q3map -vlight [-<switch> [-<switch> ...]] <mapname>\n"
05655 "\n"
05656 "Switches:\n"
05657 " v = verbose output\n"
05658 " threads <X> = set number of threads to X\n"
05659 " area <V> = set the area light scale to V\n"
05660 " point <W> = set the point light scale to W\n"
05661 " novertex = don't calculate vertex lighting\n"
05662 " nogrid = don't calculate light grid for dynamic model lighting\n"
05663 " nostitching = no polygon stitching before lighting\n"
05664 " noalphashading = don't use alpha shading\n"
05665 " nocolorshading = don't use color alpha shading\n"
05666 " tracelight = use old light algorithm by default\n"
05667 " samplesize <N> = set the lightmap pixel size to NxN units\n");
05668 exit(0);
05669 }
05670
05671 SetQdirFromPath (argv[i]);
05672
05673 #ifdef _WIN32
05674 InitPakFile(gamedir, NULL);
05675 #endif
05676
05677 strcpy (source, ExpandArg(argv[i]));
05678 StripExtension (source);
05679 D |