1 /* -------------------------------------------------------------------------------
3 Copyright (C) 1999-2007 id Software, Inc. and contributors.
4 For a list of contributors, see the accompanying CONTRIBUTORS file.
6 This file is part of GtkRadiant.
8 GtkRadiant is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 GtkRadiant is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GtkRadiant; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 ----------------------------------------------------------------------------------
24 This code has been altered significantly from its original form, to support
25 several games based on the Quake III Arena engine, in the form of "Q3Map2."
27 ------------------------------------------------------------------------------- */
42 void PlaneFromWinding( fixedWinding_t *w, visPlane_t *plane ){
46 VectorSubtract( w->points[2], w->points[1], v1 );
47 VectorSubtract( w->points[0], w->points[1], v2 );
48 CrossProduct( v2, v1, plane->normal );
49 VectorNormalize( plane->normal, plane->normal );
50 plane->dist = DotProduct( w->points[0], plane->normal );
56 returns a new fixed winding
57 ydnar: altered this a bit to reconcile multiply-defined winding_t
60 fixedWinding_t *NewFixedWinding( int points ){
64 if ( points > MAX_POINTS_ON_WINDING ) {
65 Error( "NewWinding: %i points", points );
68 size = (int)( (size_t)( (fixedWinding_t *)0 )->points[points] );
69 w = safe_malloc( size );
77 void prl( leaf_t *l ){
82 for ( i = 0 ; i < l->numportals ; i++ )
86 Sys_Printf( "portal %4i to leaf %4i : %7.1f : (%4.1f, %4.1f, %4.1f)\n",(int)( p - portals ),p->leaf,pl.dist, pl.normal[0], pl.normal[1], pl.normal[2] );
91 //=============================================================================
97 Sorts the portals from the least complex, so the later ones can reuse
98 the earlier information.
101 int PComp( const void *a, const void *b ){
102 if ( ( *(vportal_t **)a )->nummightsee == ( *(vportal_t **)b )->nummightsee ) {
105 if ( ( *(vportal_t **)a )->nummightsee < ( *(vportal_t **)b )->nummightsee ) {
110 void SortPortals( void ){
113 for ( i = 0 ; i < numportals * 2 ; i++ )
114 sorted_portals[i] = &portals[i];
119 qsort( sorted_portals, numportals * 2, sizeof( sorted_portals[0] ), PComp );
125 LeafVectorFromPortalVector
128 int LeafVectorFromPortalVector( byte *portalbits, byte *leafbits ){
134 for ( i = 0 ; i < numportals * 2 ; i++ )
136 if ( portalbits[i >> 3] & ( 1 << ( i & 7 ) ) ) {
138 leafbits[p->leaf >> 3] |= ( 1 << ( p->leaf & 7 ) );
142 for ( j = 0; j < portalclusters; j++ )
145 while ( leafs[leafnum].merged >= 0 )
146 leafnum = leafs[leafnum].merged;
147 //if the merged leaf is visible then the original leaf is visible
148 if ( leafbits[leafnum >> 3] & ( 1 << ( leafnum & 7 ) ) ) {
149 leafbits[j >> 3] |= ( 1 << ( j & 7 ) );
153 c_leafs = CountBits( leafbits, portalclusters );
163 Merges the portal visibility for a leaf
166 void ClusterMerge( int leafnum ){
168 byte portalvector[MAX_PORTALS / 8];
169 byte uncompressed[MAX_MAP_LEAFS / 8];
171 int numvis, mergedleafnum;
175 // OR together all the portalvis bits
177 mergedleafnum = leafnum;
178 while ( leafs[mergedleafnum].merged >= 0 )
179 mergedleafnum = leafs[mergedleafnum].merged;
181 memset( portalvector, 0, portalbytes );
182 leaf = &leafs[mergedleafnum];
183 for ( i = 0; i < leaf->numportals; i++ )
185 p = leaf->portals[i];
190 if ( p->status != stat_done ) {
191 Error( "portal not done" );
193 for ( j = 0 ; j < portallongs ; j++ )
194 ( (long *)portalvector )[j] |= ( (long *)p->portalvis )[j];
196 portalvector[pnum >> 3] |= 1 << ( pnum & 7 );
199 memset( uncompressed, 0, leafbytes );
201 uncompressed[mergedleafnum >> 3] |= ( 1 << ( mergedleafnum & 7 ) );
202 // convert portal bits to leaf bits
203 numvis = LeafVectorFromPortalVector( portalvector, uncompressed );
205 // if (uncompressed[leafnum>>3] & (1<<(leafnum&7)))
206 // Sys_Printf ("WARNING: Leaf portals saw into leaf\n");
208 // uncompressed[leafnum>>3] |= (1<<(leafnum&7));
210 numvis++; // count the leaf itself
214 Sys_FPrintf( SYS_VRB,"cluster %4i : %4i visible\n", leafnum, numvis );
216 memcpy( bspVisBytes + VIS_HEADER_SIZE + leafnum * leafbytes, uncompressed, leafbytes );
224 void CalcPortalVis( void ){
226 Sys_Printf( "%6d portals out of %d", 0, numportals * 2 );
227 //get rid of the counter
228 RunThreadsOnIndividual( numportals * 2, qfalse, PortalFlow );
230 RunThreadsOnIndividual( numportals * 2, qtrue, PortalFlow );
240 void CalcPassageVis( void ){
244 _printf( "%6d portals out of %d", 0, numportals * 2 );
245 RunThreadsOnIndividual( numportals * 2, qfalse, CreatePassages );
247 _printf( "%6d portals out of %d", 0, numportals * 2 );
248 RunThreadsOnIndividual( numportals * 2, qfalse, PassageFlow );
251 Sys_Printf( "\n--- CreatePassages (%d) ---\n", numportals * 2 );
252 RunThreadsOnIndividual( numportals * 2, qtrue, CreatePassages );
254 Sys_Printf( "\n--- PassageFlow (%d) ---\n", numportals * 2 );
255 RunThreadsOnIndividual( numportals * 2, qtrue, PassageFlow );
264 void CalcPassagePortalVis( void ){
268 Sys_Printf( "%6d portals out of %d", 0, numportals * 2 );
269 RunThreadsOnIndividual( numportals * 2, qfalse, CreatePassages );
271 Sys_Printf( "%6d portals out of %d", 0, numportals * 2 );
272 RunThreadsOnIndividual( numportals * 2, qfalse, PassagePortalFlow );
275 Sys_Printf( "\n--- CreatePassages (%d) ---\n", numportals * 2 );
276 RunThreadsOnIndividual( numportals * 2, qtrue, CreatePassages );
278 Sys_Printf( "\n--- PassagePortalFlow (%d) ---\n", numportals * 2 );
279 RunThreadsOnIndividual( numportals * 2, qtrue, PassagePortalFlow );
288 void CalcFastVis( void ){
291 // fastvis just uses mightsee for a very loose bound
292 for ( i = 0 ; i < numportals * 2 ; i++ )
294 portals[i].portalvis = portals[i].portalflood;
295 portals[i].status = stat_done;
304 void CalcVis( void ){
309 /* ydnar: rr2do2's farplane code */
311 value = ValueForKey( &entities[ 0 ], "_farplanedist" ); /* proper '_' prefixed key */
312 if ( value[ 0 ] == '\0' ) {
313 value = ValueForKey( &entities[ 0 ], "fogclip" ); /* wolf compatibility */
315 if ( value[ 0 ] == '\0' ) {
316 value = ValueForKey( &entities[ 0 ], "distancecull" ); /* sof2 compatibility */
318 if ( value[ 0 ] != '\0' ) {
319 farPlaneDist = atof( value );
320 if ( farPlaneDist > 0.0f ) {
321 Sys_Printf( "farplane distance = %.1f\n", farPlaneDist );
330 Sys_Printf( "\n--- BasePortalVis (%d) ---\n", numportals * 2 );
331 RunThreadsOnIndividual( numportals * 2, qtrue, BasePortalVis );
333 // RunThreadsOnIndividual (numportals*2, qtrue, BetterPortalVis);
340 else if ( noPassageVis ) {
343 else if ( passageVisOnly ) {
347 CalcPassagePortalVis();
350 // assemble the leaf vis lists by oring and compressing the portal lists
352 Sys_Printf( "creating leaf vis...\n" );
353 for ( i = 0 ; i < portalclusters ; i++ )
356 Sys_Printf( "Total visible clusters: %i\n", totalvis );
357 Sys_Printf( "Average clusters visible: %i\n", totalvis / portalclusters );
365 void SetPortalSphere( vportal_t *p ){
372 VectorCopy( vec3_origin, total );
373 for ( i = 0 ; i < w->numpoints ; i++ )
375 VectorAdd( total, w->points[i], total );
378 for ( i = 0 ; i < 3 ; i++ )
379 total[i] /= w->numpoints;
382 for ( i = 0 ; i < w->numpoints ; i++ )
384 VectorSubtract( w->points[i], total, dist );
385 r = VectorLength( dist );
390 VectorCopy( total, p->origin );
396 Winding_PlanesConcave
399 #define WCONVEX_EPSILON 0.2
401 int Winding_PlanesConcave( fixedWinding_t *w1, fixedWinding_t *w2,
402 vec3_t normal1, vec3_t normal2,
403 float dist1, float dist2 ){
410 // check if one of the points of winding 1 is at the front of the plane of winding 2
411 for ( i = 0; i < w1->numpoints; i++ )
413 if ( DotProduct( normal2, w1->points[i] ) - dist2 > WCONVEX_EPSILON ) {
417 // check if one of the points of winding 2 is at the front of the plane of winding 1
418 for ( i = 0; i < w2->numpoints; i++ )
420 if ( DotProduct( normal1, w2->points[i] ) - dist1 > WCONVEX_EPSILON ) {
433 int TryMergeLeaves( int l1num, int l2num ){
434 int i, j, k, n, numportals;
435 visPlane_t plane1, plane2;
438 vportal_t *portals[MAX_PORTALS_ON_LEAF];
440 for ( k = 0; k < 2; k++ )
445 else{l1 = &faceleafs[l1num]; }
446 for ( i = 0; i < l1->numportals; i++ )
449 if ( p1->leaf == l2num ) {
452 for ( n = 0; n < 2; n++ )
457 else{l2 = &faceleafs[l2num]; }
458 for ( j = 0; j < l2->numportals; j++ )
461 if ( p2->leaf == l1num ) {
467 if ( Winding_PlanesConcave( p1->winding, p2->winding, plane1.normal, plane2.normal, plane1.dist, plane2.dist ) ) {
474 for ( k = 0; k < 2; k++ )
482 l1 = &faceleafs[l1num];
483 l2 = &faceleafs[l2num];
486 //the leaves can be merged now
487 for ( i = 0; i < l1->numportals; i++ )
490 if ( p1->leaf == l2num ) {
494 portals[numportals++] = p1;
496 for ( j = 0; j < l2->numportals; j++ )
499 if ( p2->leaf == l1num ) {
503 portals[numportals++] = p2;
505 for ( i = 0; i < numportals; i++ )
507 l2->portals[i] = portals[i];
509 l2->numportals = numportals;
520 void UpdatePortals( void ){
524 for ( i = 0; i < numportals * 2; i++ )
530 while ( leafs[p->leaf].merged >= 0 )
531 p->leaf = leafs[p->leaf].merged;
539 try to merge leaves but don't merge through hint splitters
542 void MergeLeaves( void ){
543 int i, j, nummerges, totalnummerges;
551 for ( i = 0; i < portalclusters; i++ )
554 //if this leaf is merged already
556 /* ydnar: vmods: merge all non-hint portals */
557 if ( leaf->merged >= 0 && hint == qfalse ) {
562 for ( j = 0; j < leaf->numportals; j++ )
564 p = leaf->portals[j];
569 //never merge through hint portals
573 if ( TryMergeLeaves( i, p->leaf ) ) {
580 totalnummerges += nummerges;
581 } while ( nummerges );
582 Sys_Printf( "%6d leaves merged\n", totalnummerges );
590 #define CONTINUOUS_EPSILON 0.005
592 fixedWinding_t *TryMergeWinding( fixedWinding_t *f1, fixedWinding_t *f2, vec3_t planenormal ){
593 vec_t *p1, *p2, *p3, *p4, *back;
594 fixedWinding_t *newf;
596 vec3_t normal, delta;
598 qboolean keep1, keep2;
602 // find a common edge
604 p1 = p2 = NULL; // stop compiler warning
607 for ( i = 0; i < f1->numpoints; i++ )
610 p2 = f1->points[( i + 1 ) % f1->numpoints];
611 for ( j = 0; j < f2->numpoints; j++ )
614 p4 = f2->points[( j + 1 ) % f2->numpoints];
615 for ( k = 0; k < 3; k++ )
617 if ( fabs( p1[k] - p4[k] ) > 0.1 ) { //EQUAL_EPSILON) //ME
620 if ( fabs( p2[k] - p3[k] ) > 0.1 ) { //EQUAL_EPSILON) //ME
628 if ( j < f2->numpoints ) {
633 if ( i == f1->numpoints ) {
634 return NULL; // no matching edges
638 // check slope of connected lines
639 // if the slopes are colinear, the point can be removed
641 back = f1->points[( i + f1->numpoints - 1 ) % f1->numpoints];
642 VectorSubtract( p1, back, delta );
643 CrossProduct( planenormal, delta, normal );
644 VectorNormalize( normal, normal );
646 back = f2->points[( j + 2 ) % f2->numpoints];
647 VectorSubtract( back, p1, delta );
648 dot = DotProduct( delta, normal );
649 if ( dot > CONTINUOUS_EPSILON ) {
650 return NULL; // not a convex polygon
652 keep1 = (qboolean)( dot < -CONTINUOUS_EPSILON );
654 back = f1->points[( i + 2 ) % f1->numpoints];
655 VectorSubtract( back, p2, delta );
656 CrossProduct( planenormal, delta, normal );
657 VectorNormalize( normal, normal );
659 back = f2->points[( j + f2->numpoints - 1 ) % f2->numpoints];
660 VectorSubtract( back, p2, delta );
661 dot = DotProduct( delta, normal );
662 if ( dot > CONTINUOUS_EPSILON ) {
663 return NULL; // not a convex polygon
665 keep2 = (qboolean)( dot < -CONTINUOUS_EPSILON );
668 // build the new polygon
670 newf = NewFixedWinding( f1->numpoints + f2->numpoints );
672 // copy first polygon
673 for ( k = ( i + 1 ) % f1->numpoints ; k != i ; k = ( k + 1 ) % f1->numpoints )
675 if ( k == ( i + 1 ) % f1->numpoints && !keep2 ) {
679 VectorCopy( f1->points[k], newf->points[newf->numpoints] );
683 // copy second polygon
684 for ( l = ( j + 1 ) % f2->numpoints ; l != j ; l = ( l + 1 ) % f2->numpoints )
686 if ( l == ( j + 1 ) % f2->numpoints && !keep1 ) {
689 VectorCopy( f2->points[l], newf->points[newf->numpoints] );
701 void MergeLeafPortals( void ){
702 int i, j, k, nummerges, hintsmerged;
709 for ( i = 0; i < portalclusters; i++ )
712 if ( leaf->merged >= 0 ) {
715 for ( j = 0; j < leaf->numportals; j++ )
717 p1 = leaf->portals[j];
721 for ( k = j + 1; k < leaf->numportals; k++ )
723 p2 = leaf->portals[k];
727 if ( p1->leaf == p2->leaf ) {
728 w = TryMergeWinding( p1->winding, p2->winding, p1->plane.normal );
730 free( p1->winding ); //% FreeWinding(p1->winding);
732 if ( p1->hint && p2->hint ) {
735 p1->hint |= p2->hint;
736 SetPortalSphere( p1 );
744 if ( k < leaf->numportals ) {
749 Sys_Printf( "%6d portals merged\n", nummerges );
750 Sys_Printf( "%6d hint portals merged\n", hintsmerged );
759 int CountActivePortals( void ){
765 for ( j = 0; j < numportals * 2; j++ )
776 Sys_Printf( "%6d active portals\n", num );
777 Sys_Printf( "%6d hint portals\n", hints );
786 void WriteFloat( FILE *f, vec_t v );
788 void WritePortals( char *filename ){
795 pf = fopen( filename, "w" );
797 Error( "Error opening %s", filename );
801 for ( j = 0; j < numportals * 2; j++ )
812 fprintf( pf, "%s\n", PORTALFILE );
813 fprintf( pf, "%i\n", 0 );
814 fprintf( pf, "%i\n", num ); // + numfaces);
815 fprintf( pf, "%i\n", 0 );
817 for ( j = 0; j < numportals * 2; j++ )
826 fprintf( pf,"%i %i %i ",w->numpoints, 0, 0 );
827 fprintf( pf, "%d ", p->hint );
828 for ( i = 0 ; i < w->numpoints ; i++ )
831 WriteFloat( pf, w->points[i][0] );
832 WriteFloat( pf, w->points[i][1] );
833 WriteFloat( pf, w->points[i][2] );
840 for (j = 0; j < numfaces; j++)
844 fprintf (pf,"%i %i %i ",w->numpoints, 0, 0);
846 for (i=0 ; i<w->numpoints ; i++)
849 WriteFloat (pf, w->points[i][0]);
850 WriteFloat (pf, w->points[i][1]);
851 WriteFloat (pf, w->points[i][2]);
865 void LoadPortals( char *name ){
876 if ( !strcmp( name,"-" ) ) {
881 f = fopen( name, "r" );
883 Error( "LoadPortals: couldn't read %s\n",name );
887 if ( fscanf( f,"%79s\n%i\n%i\n%i\n",magic, &portalclusters, &numportals, &numfaces ) != 4 ) {
888 Error( "LoadPortals: failed to read header" );
890 if ( strcmp( magic,PORTALFILE ) ) {
891 Error( "LoadPortals: not a portal file" );
894 Sys_Printf( "%6i portalclusters\n", portalclusters );
895 Sys_Printf( "%6i numportals\n", numportals );
896 Sys_Printf( "%6i numfaces\n", numfaces );
898 // these counts should take advantage of 64 bit systems automatically
899 leafbytes = ( ( portalclusters + 63 ) & ~63 ) >> 3;
900 leaflongs = leafbytes / sizeof( long );
902 portalbytes = ( ( numportals * 2 + 63 ) & ~63 ) >> 3;
903 portallongs = portalbytes / sizeof( long );
905 // each file portal is split into two memory portals
906 portals = safe_malloc( 2 * numportals * sizeof( vportal_t ) );
907 memset( portals, 0, 2 * numportals * sizeof( vportal_t ) );
909 leafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
910 memset( leafs, 0, portalclusters * sizeof( leaf_t ) );
912 for ( i = 0; i < portalclusters; i++ )
913 leafs[i].merged = -1;
915 numBSPVisBytes = VIS_HEADER_SIZE + portalclusters * leafbytes;
917 if ( numBSPVisBytes > MAX_MAP_VISIBILITY ) {
918 Error( "MAX_MAP_VISIBILITY exceeded" );
921 ( (int *)bspVisBytes )[0] = portalclusters;
922 ( (int *)bspVisBytes )[1] = leafbytes;
924 for ( i = 0, p = portals ; i < numportals ; i++ )
926 if ( fscanf( f, "%i %i %i ", &numpoints, &leafnums[0], &leafnums[1] ) != 3 ) {
927 Error( "LoadPortals: reading portal %i", i );
929 if ( numpoints > MAX_POINTS_ON_WINDING ) {
930 Error( "LoadPortals: portal %i has too many points", i );
932 if ( (unsigned)leafnums[0] > portalclusters
933 || (unsigned)leafnums[1] > portalclusters ) {
934 Error( "LoadPortals: reading portal %i", i );
936 if ( fscanf( f, "%i ", &hint ) != 1 ) {
937 Error( "LoadPortals: reading hint state" );
940 w = p->winding = NewFixedWinding( numpoints );
941 w->numpoints = numpoints;
943 for ( j = 0 ; j < numpoints ; j++ )
948 // scanf into double, then assign to vec_t
949 // so we don't care what size vec_t is
950 if ( fscanf( f, "(%lf %lf %lf ) "
951 , &v[0], &v[1], &v[2] ) != 3 ) {
952 Error( "LoadPortals: reading portal %i", i );
954 for ( k = 0 ; k < 3 ; k++ )
955 w->points[j][k] = v[k];
960 PlaneFromWinding( w, &plane );
962 // create forward portal
963 l = &leafs[leafnums[0]];
964 if ( l->numportals == MAX_PORTALS_ON_LEAF ) {
965 Error( "Leaf with too many portals" );
967 l->portals[l->numportals] = p;
973 VectorSubtract( vec3_origin, plane.normal, p->plane.normal );
974 p->plane.dist = -plane.dist;
975 p->leaf = leafnums[1];
976 SetPortalSphere( p );
979 // create backwards portal
980 l = &leafs[leafnums[1]];
981 if ( l->numportals == MAX_PORTALS_ON_LEAF ) {
982 Error( "Leaf with too many portals" );
984 l->portals[l->numportals] = p;
989 p->winding = NewFixedWinding( w->numpoints );
990 p->winding->numpoints = w->numpoints;
991 for ( j = 0 ; j < w->numpoints ; j++ )
993 VectorCopy( w->points[w->numpoints - 1 - j], p->winding->points[j] );
997 p->leaf = leafnums[0];
998 SetPortalSphere( p );
1003 faces = safe_malloc( 2 * numfaces * sizeof( vportal_t ) );
1004 memset( faces, 0, 2 * numfaces * sizeof( vportal_t ) );
1006 faceleafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
1007 memset( faceleafs, 0, portalclusters * sizeof( leaf_t ) );
1009 for ( i = 0, p = faces; i < numfaces; i++ )
1011 if ( fscanf( f, "%i %i ", &numpoints, &leafnums[0] ) != 2 ) {
1012 Error( "LoadPortals: reading portal %i", i );
1015 w = p->winding = NewFixedWinding( numpoints );
1016 w->numpoints = numpoints;
1018 for ( j = 0 ; j < numpoints ; j++ )
1023 // scanf into double, then assign to vec_t
1024 // so we don't care what size vec_t is
1025 if ( fscanf( f, "(%lf %lf %lf ) "
1026 , &v[0], &v[1], &v[2] ) != 3 ) {
1027 Error( "LoadPortals: reading portal %i", i );
1029 for ( k = 0 ; k < 3 ; k++ )
1030 w->points[j][k] = v[k];
1035 PlaneFromWinding( w, &plane );
1037 l = &faceleafs[leafnums[0]];
1039 if ( l->numportals == MAX_PORTALS_ON_LEAF ) {
1040 Error( "Leaf with too many faces" );
1042 l->portals[l->numportals] = p;
1047 // normal pointing out of the leaf
1048 VectorSubtract( vec3_origin, plane.normal, p->plane.normal );
1049 p->plane.dist = -plane.dist;
1051 SetPortalSphere( p );
1065 int VisMain( int argc, char **argv ){
1066 char portalfile[1024];
1071 Sys_Printf( "--- Vis ---\n" );
1073 /* process arguments */
1074 for ( i = 1 ; i < ( argc - 1 ) ; i++ )
1076 if ( !strcmp( argv[i], "-fast" ) ) {
1077 Sys_Printf( "fastvis = true\n" );
1080 else if ( !strcmp( argv[i], "-merge" ) ) {
1081 Sys_Printf( "merge = true\n" );
1084 else if ( !strcmp( argv[i], "-nopassage" ) ) {
1085 Sys_Printf( "nopassage = true\n" );
1086 noPassageVis = qtrue;
1088 else if ( !strcmp( argv[i], "-passageOnly" ) ) {
1089 Sys_Printf( "passageOnly = true\n" );
1090 passageVisOnly = qtrue;
1092 else if ( !strcmp( argv[i],"-nosort" ) ) {
1093 Sys_Printf( "nosort = true\n" );
1096 else if ( !strcmp( argv[i],"-saveprt" ) ) {
1097 Sys_Printf( "saveprt = true\n" );
1100 else if ( !strcmp( argv[i],"-tmpin" ) ) {
1101 strcpy( inbase, "/tmp" );
1103 else if ( !strcmp( argv[i],"-tmpout" ) ) {
1104 strcpy( outbase, "/tmp" );
1108 /* ydnar: -hint to merge all but hint portals */
1109 else if ( !strcmp( argv[ i ], "-hint" ) ) {
1110 Sys_Printf( "hint = true\n" );
1116 Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
1120 if ( i != argc - 1 ) {
1121 Error( "usage: vis [-threads #] [-level 0-4] [-fast] [-v] bspfile" );
1126 sprintf( source, "%s%s", inbase, ExpandArg( argv[ i ] ) );
1127 StripExtension( source );
1128 strcat( source, ".bsp" );
1129 Sys_Printf( "Loading %s\n", source );
1130 LoadBSPFile( source );
1132 /* load the portal file */
1133 sprintf( portalfile, "%s%s", inbase, ExpandArg( argv[ i ] ) );
1134 StripExtension( portalfile );
1135 strcat( portalfile, ".prt" );
1136 Sys_Printf( "Loading %s\n", portalfile );
1137 LoadPortals( portalfile );
1139 /* ydnar: exit if no portals, hence no vis */
1140 if ( numportals == 0 ) {
1141 Sys_Printf( "No portals means no vis, exiting.\n" );
1145 /* ydnar: for getting far plane */
1153 CountActivePortals();
1154 /* WritePortals( "maps/hints.prs" );*/
1156 Sys_Printf( "visdatasize:%i\n", numBSPVisBytes );
1160 /* delete the prt file */
1162 remove( portalfile );
1165 /* write the bsp file */
1166 Sys_Printf( "Writing %s\n", source );
1167 WriteBSPFile( source );