]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3map2/vis.c
Merge commit 'e28939e7b819e0cb0c3050037ec0e57160f7dba1' into master-merge
[xonotic/netradiant.git] / tools / quake3 / q3map2 / vis.c
index 702b7bfe1cd144597298eff3b7005f9576d3558c..5e3bf7efeb64b320f6d31b0be1fde93c94b63c3a 100644 (file)
@@ -66,8 +66,7 @@ fixedWinding_t *NewFixedWinding( int points ){
        }
 
        size = (int)( (size_t)( (fixedWinding_t *)0 )->points[points] );
-       w = safe_malloc( size );
-       memset( w, 0, size );
+       w = safe_malloc0( size );
 
        return w;
 }
@@ -163,7 +162,9 @@ int LeafVectorFromPortalVector( byte *portalbits, byte *leafbits ){
    Merges the portal visibility for a leaf
    ===============
  */
+
 static int clustersizehistogram[MAX_MAP_LEAFS] = {0};
+
 void ClusterMerge( int leafnum ){
        leaf_t      *leaf;
        byte portalvector[MAX_PORTALS / 8];
@@ -204,13 +205,13 @@ void ClusterMerge( int leafnum ){
        numvis = LeafVectorFromPortalVector( portalvector, uncompressed );
 
 //     if (uncompressed[leafnum>>3] & (1<<(leafnum&7)))
-//             Sys_Printf ("WARNING: Leaf portals saw into leaf\n");
+//             Sys_FPrintf (SYS_WRN, "WARNING: Leaf portals saw into leaf\n");
 
 //     uncompressed[leafnum>>3] |= (1<<(leafnum&7));
 
        numvis++;       // count the leaf itself
 
-       //Sys_FPrintf (SYS_VRB,"cluster %4i : %4i visible\n", leafnum, numvis);
+       //Sys_FPrintf( SYS_VRB,"cluster %4i : %4i visible\n", leafnum, numvis );
        ++clustersizehistogram[numvis];
 
        memcpy( bspVisBytes + VIS_HEADER_SIZE + leafnum * leafbytes, uncompressed, leafbytes );
@@ -318,16 +319,25 @@ void CalcVis( void ){
        }
        if ( value[ 0 ] != '\0' ) {
                farPlaneDist = atof( value );
-               if ( farPlaneDist > 0.0f ) {
+               farPlaneDistMode = value[strlen(value) - 1 ];
+               if ( farPlaneDist != 0.0f ) {
                        Sys_Printf( "farplane distance = %.1f\n", farPlaneDist );
                }
-               else{
-                       farPlaneDist = 0.0f;
+                       if ( farPlaneDist != 0.0f && farPlaneDistMode == 'o' ) {
+                       Sys_Printf( "farplane Origin2Origin mode on\n" );
+               }
+                       if ( farPlaneDist != 0.0f && farPlaneDistMode == 'r' ) {
+                       Sys_Printf( "farplane Radius+Radius mode on\n" );
                }
+                       if ( farPlaneDist != 0.0f && farPlaneDistMode == 'e' ) {
+                       Sys_Printf( "farplane Exact distance mode on\n" );
+               }
+
        }
 
 
 
+
        Sys_Printf( "\n--- BasePortalVis (%d) ---\n", numportals * 2 );
        RunThreadsOnIndividual( numportals * 2, qtrue, BasePortalVis );
 
@@ -934,11 +944,9 @@ void LoadPortals( char *name ){
        portallongs = portalbytes / sizeof( long );
 
        // each file portal is split into two memory portals
-       portals = safe_malloc( 2 * numportals * sizeof( vportal_t ) );
-       memset( portals, 0, 2 * numportals * sizeof( vportal_t ) );
+       portals = safe_malloc0( 2 * numportals * sizeof( vportal_t ) );
 
-       leafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
-       memset( leafs, 0, portalclusters * sizeof( leaf_t ) );
+       leafs = safe_malloc0( portalclusters * sizeof( leaf_t ) );
 
        for ( i = 0; i < portalclusters; i++ )
                leafs[i].merged = -1;
@@ -1034,11 +1042,9 @@ void LoadPortals( char *name ){
 
        }
 
-       faces = safe_malloc( 2 * numfaces * sizeof( vportal_t ) );
-       memset( faces, 0, 2 * numfaces * sizeof( vportal_t ) );
+       faces = safe_malloc0( 2 * numfaces * sizeof( vportal_t ) );
 
-       faceleafs = safe_malloc( portalclusters * sizeof( leaf_t ) );
-       memset( faceleafs, 0, portalclusters * sizeof( leaf_t ) );
+       faceleafs = safe_malloc0( portalclusters * sizeof( leaf_t ) );
 
        for ( i = 0, p = faces; i < numfaces; i++ )
        {
@@ -1140,7 +1146,7 @@ int VisMain( int argc, char **argv ){
                }
                else if ( !strcmp( argv[ i ], "-v" ) ) {
                        debugCluster = qtrue;
-                       Sys_Printf( "Extra verbous mode enabled\n" );
+                       Sys_Printf( "Extra verbose mode enabled\n" );
                }
                else if ( !strcmp( argv[i],"-tmpin" ) ) {
                        strcpy( inbase, "/tmp" );
@@ -1158,18 +1164,19 @@ int VisMain( int argc, char **argv ){
                else if ( !strcmp( argv[ i ], "-prtfile" ) )
                {
                        strcpy( portalFilePath, argv[i + 1] );
+                       argv[ i ] = NULL;
                        i++;
+                       argv[ i ] = NULL;
                        Sys_Printf( "Use %s as portal file\n", portalFilePath );
                }
 
-               else
-               {
-                       Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] );
+               else{
+                       Sys_FPrintf( SYS_WRN, "WARNING: Unknown option \"%s\"\n", argv[ i ] );
                }
        }
 
        if ( i != argc - 1 ) {
-               Error( "usage: vis [-threads #] [-level 0-4] [-fast] [-v] BSPFilePath" );
+               Error( "usage: vis [-threads #] [-fast] [-v] BSPFilePath" );
        }
 
 
@@ -1180,14 +1187,24 @@ int VisMain( int argc, char **argv ){
        Sys_Printf( "Loading %s\n", source );
        LoadBSPFile( source );
 
+       if ( game->texFile )
+       {
+               // smokinguns-like tex file
+               StripExtension( source );
+               strcat( source, ".tex" );
+               LoadSurfaceFlags( source );
+               StripExtension( source );
+               strcat( source, ".bsp" );
+       }
+
        /* load the portal file */
        if (!portalFilePath[0]) {
                sprintf( portalFilePath, "%s%s", inbase, ExpandArg( argv[ i ] ) );
                StripExtension( portalFilePath );
                strcat( portalFilePath, ".prt" );
-               Sys_Printf( "Loading %s\n", portalFilePath );
-               LoadPortals( portalFilePath );
        }
+       Sys_Printf( "Loading %s\n", portalFilePath );
+       LoadPortals( portalFilePath );
 
        /* ydnar: exit if no portals, hence no vis */
        if ( numportals == 0 ) {
@@ -1222,6 +1239,14 @@ int VisMain( int argc, char **argv ){
                remove( portalFilePath );
        }
 
+       if ( game->texFile )
+       {
+               // smokinguns-like tex file
+               StripExtension( source );
+               WriteTexFile( source );
+               DefaultExtension( source, ".bsp" );
+       }
+
        /* write the bsp file */
        Sys_Printf( "Writing %s\n", source );
        WriteBSPFile( source );