X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=tools%2Fquake3%2Fq3map2%2Fbsp.c;h=7e504a6a2f8fee3bba0f43d6a84622989716a2fc;hb=bdd92181b3b41baf91319b5632a5ee85295b3e04;hp=da7374605d32fa698044fbeae938d254628d045e;hpb=7fc621fc78d0e040dc2c12f38dc53dd9048215dc;p=xonotic%2Fnetradiant.git diff --git a/tools/quake3/q3map2/bsp.c b/tools/quake3/q3map2/bsp.c index da737460..7e504a6a 100644 --- a/tools/quake3/q3map2/bsp.c +++ b/tools/quake3/q3map2/bsp.c @@ -193,7 +193,7 @@ static void SetCloneModelNumbers( void ){ /* get the model num */ value3 = ValueForKey( &entities[ j ], "model" ); if ( value3[ 0 ] == '\0' ) { - Sys_Printf( "WARNING: Cloned entity %s referenced entity without model\n", value2 ); + Sys_FPrintf( SYS_WRN, "WARNING: Cloned entity %s referenced entity without model\n", value2 ); continue; } models = atoi( &value2[ 1 ] ); @@ -265,7 +265,7 @@ static void FixBrushSides( entity_t *e ){ creates a full bsp + surfaces for the worldspawn entity */ -void ProcessWorldModel( void ){ +void ProcessWorldModel( const char *portalFilePath, const char *lineFilePath ){ int i, s; entity_t *e; tree_t *tree; @@ -319,6 +319,10 @@ void ProcessWorldModel( void ){ /* check for patches with adjacent edges that need to lod together */ PatchMapDrawSurfs( e ); + if ( debugClip ) { + AddTriangleModels( e ); + } + /* build an initial bsp tree using all of the sides of all of the structural brushes */ faces = MakeStructuralBSPFaceList( entities[ 0 ].brushes ); tree = FaceBSP( faces ); @@ -343,9 +347,9 @@ void ProcessWorldModel( void ){ Sys_FPrintf( SYS_NOXML, "**********************\n" ); Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" ); Sys_FPrintf( SYS_NOXML, "**********************\n" ); - polyline = LeakFile( tree ); + polyline = LeakFile( tree, lineFilePath ); leaknode = xmlNewNode( NULL, (xmlChar*)"message" ); - xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" ); + xmlNodeAddContent( leaknode, (xmlChar*)"MAP LEAKED\n" ); xmlAddChild( leaknode, polyline ); level[0] = (int) '0' + SYS_ERR; level[1] = 0; @@ -380,14 +384,16 @@ void ProcessWorldModel( void ){ /* save out information for visibility processing */ NumberClusters( tree ); if ( !leaked ) { - WritePortalFile( tree ); + WritePortalFile( tree, portalFilePath ); } /* flood from entities */ FloodAreas( tree ); /* create drawsurfs for triangle models */ - AddTriangleModels( e ); + if ( !debugClip ) { + AddTriangleModels( e ); + } /* create drawsurfs for surface models */ AddEntitySurfaceModels( e ); @@ -592,7 +598,7 @@ void ProcessSubModel( void ){ process world + other models into the bsp */ -void ProcessModels( void ){ +void ProcessModels( const char *portalFilePath, const char *lineFilePath ){ qboolean oldVerbose; entity_t *entity; @@ -618,7 +624,7 @@ void ProcessModels( void ){ /* process the model */ Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels ); if ( mapEntityNum == 0 ) { - ProcessWorldModel(); + ProcessWorldModel(portalFilePath, lineFilePath); } else{ ProcessSubModel(); @@ -631,6 +637,8 @@ void ProcessModels( void ){ /* restore -v setting */ verbose = oldVerbose; + Sys_FPrintf( SYS_VRB, "%9i bspModels in total\n", numBSPModels ); + /* write fogs */ EmitFogs(); @@ -645,17 +653,14 @@ void ProcessModels( void ){ this is probably broken unless teamed with a radiant version that preserves entity order */ -void OnlyEnts( void ){ - char out[ 1024 ]; - +void OnlyEnts( const char *BSPFilePath ){ char save_cmdline[1024], save_version[1024], save_gridsize[1024]; const char *p; /* note it */ Sys_Printf( "--- OnlyEnts ---\n" ); - sprintf( out, "%s.bsp", source ); - LoadBSPFile( out ); + LoadBSPFile( BSPFilePath ); ParseEntities(); p = ValueForKey( &entities[0], "_q3map2_cmdline" ); @@ -688,7 +693,7 @@ void OnlyEnts( void ){ numBSPEntities = numEntities; UnparseEntities(); - WriteBSPFile( out ); + WriteBSPFile( BSPFilePath ); } @@ -702,14 +707,26 @@ int BSPMain( int argc, char **argv ){ int i; char path[ 1024 ], tempSource[ 1024 ]; qboolean onlyents = qfalse; - + char BSPFilePath [ 1024 ]; + char lineFilePath [ 1024 ]; + char portalFilePath [ 1024 ]; + char surfaceFilePath [ 1024 ]; + BSPFilePath[0] = 0; + lineFilePath[0] = 0; + portalFilePath[0] = 0; + surfaceFilePath[0] = 0; + + if ( argc >= 2 && !strcmp( argv[ 1 ], "-bsp" ) ) { + argv++; + argc--; + } /* note it */ Sys_Printf( "--- BSP ---\n" ); + doingBSP = qtrue; SetDrawSurfacesBuffer(); - mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS ); - memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS ); + mapDrawSurfs = safe_malloc0( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS ); numMapDrawSurfs = 0; tempSource[ 0 ] = '\0'; @@ -817,7 +834,37 @@ int BSPMain( int argc, char **argv ){ i++; Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon ); } - else if ( !strcmp( argv[ i ], "-mv" ) ) { + else if ( !strcmp( argv[ i ], "-fastmeta" ) ) { + maxLMSurfaceVerts = 64; + maxSurfaceVerts = 999; + maxSurfaceIndexes = 6000; + Sys_Printf( "Maximum per-surface vertex count set to %d\n", maxSurfaceVerts ); + Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes ); + Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts ); + } + else if ( !strcmp( argv[ i ], "-maxsurfacevertices" ) ) { + maxSurfaceVerts = atoi( argv[ i + 1 ] ); + if ( maxSurfaceVerts < 3 ) { + maxSurfaceVerts = 3; + } + i++; + Sys_Printf( "Maximum per-surface vertex count set to %d\n", maxSurfaceVerts ); + } + else if ( !strcmp( argv[ i ], "-maxsurfaceindexes" ) || !strcmp( argv[ i ], "-mi" ) ) { + maxSurfaceIndexes = atoi( argv[ i + 1 ] ); + if ( maxSurfaceIndexes < 3 ) { + maxSurfaceIndexes = 3; + } + i++; + + if ( !strcmp( argv[ i ], "-mi" ) ) { + Sys_Printf( "The -mi argument is deprecated, use \"-maxsurfaceindexes\" instead\n" ); + } + else { + Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes ); + } + } + else if ( !strcmp( argv[ i ], "-maxlightmapvertices" ) || !strcmp( argv[ i ], "-mv" ) ) { maxLMSurfaceVerts = atoi( argv[ i + 1 ] ); if ( maxLMSurfaceVerts < 3 ) { maxLMSurfaceVerts = 3; @@ -826,15 +873,13 @@ int BSPMain( int argc, char **argv ){ maxSurfaceVerts = maxLMSurfaceVerts; } i++; + + if ( !strcmp( argv[ i ], "-mv" ) ) { + Sys_Printf( "The -mv argument is deprecated, use \"-maxlightmapvertices\" instead\n" ); + } + else { Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts ); } - else if ( !strcmp( argv[ i ], "-mi" ) ) { - maxSurfaceIndexes = atoi( argv[ i + 1 ] ); - if ( maxSurfaceIndexes < 3 ) { - maxSurfaceIndexes = 3; - } - i++; - Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes ); } else if ( !strcmp( argv[ i ], "-np" ) ) { npDegrees = atof( argv[ i + 1 ] ); @@ -944,6 +989,15 @@ int BSPMain( int argc, char **argv ){ Sys_Printf( "Debug portal surfaces enabled\n" ); debugPortals = qtrue; } + else if ( !strcmp( argv[ i ], "-debugclip" ) ) { + Sys_Printf( "Debug model clip enabled\n" ); + debugClip = qtrue; + } + else if ( !strcmp( argv[ i ], "-clipdepth" ) ) { + clipDepthGlobal = atof( argv[ i + 1 ] ); + i++; + Sys_Printf( "Model autoclip thickness set to %.3f\n", clipDepthGlobal ); + } else if ( !strcmp( argv[ i ], "-sRGBtex" ) ) { texturesRGB = qtrue; Sys_Printf( "Textures are in sRGB\n" ); @@ -978,8 +1032,41 @@ int BSPMain( int argc, char **argv ){ Sys_Printf( "Max Area face surface generation enabled\n" ); maxAreaFaceSurface = qtrue; } - else if ( !strcmp( argv[ i ], "-bsp" ) ) { - Sys_Printf( "-bsp argument unnecessary\n" ); + else if ( !strcmp( argv[ i ], "-bspfile" ) ) + { + strcpy( BSPFilePath, argv[i + 1] ); + argv[ i ] = NULL; + i++; + argv[ i ] = NULL; + Sys_Printf( "Use %s as bsp file\n", BSPFilePath ); + } + else if ( !strcmp( argv[ i ], "-linfile" ) ) + { + strcpy( lineFilePath, argv[i + 1] ); + argv[ i ] = NULL; + i++; + argv[ i ] = NULL; + Sys_Printf( "Use %s as line file\n", lineFilePath ); + } + 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 if ( !strcmp( argv[ i ], "-srffile" ) ) + { + strcpy( surfaceFilePath, argv[i + 1] ); + argv[ i ] = NULL; + i++; + argv[ i ] = NULL; + Sys_Printf( "Use %s as surface file\n", surfaceFilePath ); + } + else if ( !strcmp( argv[ i ], "-noob" ) ) { + Sys_Printf( "No oBs!\n" ); + noob = qtrue; } else { @@ -999,13 +1086,23 @@ int BSPMain( int argc, char **argv ){ /* ydnar: set default sample size */ SetDefaultSampleSize( sampleSize ); + if (!BSPFilePath[0]) { + sprintf( BSPFilePath, "%s.bsp", source ); + } + if (!lineFilePath[0]) { + sprintf( lineFilePath, "%s.lin", source ); + } + if (!portalFilePath[0]) { + sprintf( portalFilePath, "%s.prt", source ); + } + if (!surfaceFilePath[0]) { + sprintf( surfaceFilePath, "%s.srf", source ); + } + /* delete portal, line and surface files */ - sprintf( path, "%s.prt", source ); - remove( path ); - sprintf( path, "%s.lin", source ); - remove( path ); - //% sprintf( path, "%s.srf", source ); /* ydnar */ - //% remove( path ); + remove( portalFilePath ); + remove( lineFilePath ); + //% remove( surfaceFilePath ) /* ydnar */ /* expand mapname */ strcpy( name, ExpandArg( argv[ i ] ) ); @@ -1018,7 +1115,7 @@ int BSPMain( int argc, char **argv ){ /* if onlyents, just grab the entites and resave */ if ( onlyents ) { - OnlyEnts(); + OnlyEnts( BSPFilePath ); return 0; } @@ -1043,7 +1140,7 @@ int BSPMain( int argc, char **argv ){ SetCloneModelNumbers(); /* process world and submodels */ - ProcessModels(); + ProcessModels( portalFilePath, lineFilePath ); /* set light styles from targetted light entities */ SetLightStyles(); @@ -1052,7 +1149,7 @@ int BSPMain( int argc, char **argv ){ ProcessAdvertisements(); /* finish and write bsp */ - EndBSPFile( qtrue ); + EndBSPFile( qtrue, BSPFilePath, surfaceFilePath ); /* remove temp map source file if appropriate */ if ( strlen( tempSource ) > 0 ) {