//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== tree_t *ProcessWorldBrushes( int brush_start, int brush_end ) { bspbrush_t *brushes; tree_t *tree; node_t *node; vec3_t mins, maxs; //take the whole world mins[0] = map_mins[0] - 8; mins[1] = map_mins[1] - 8; mins[2] = map_mins[2] - 8; maxs[0] = map_maxs[0] + 8; maxs[1] = map_maxs[1] + 8; maxs[2] = map_maxs[2] + 8; //reset the brush bsp ResetBrushBSP(); // the makelist and chopbrushes could be cached between the passes... //create a list with brushes that are within the given mins/maxs //some brushes will be cut and only the part that falls within the //mins/maxs will be in the bush list brushes = MakeBspBrushList( brush_start, brush_end, mins, maxs ); // if ( !brushes ) { node = AllocNode(); node->planenum = PLANENUM_LEAF; node->contents = CONTENTS_SOLID; tree = Tree_Alloc(); tree->headnode = node; VectorCopy( mins, tree->mins ); VectorCopy( maxs, tree->maxs ); } //end if else { //Carves any intersecting solid brushes into the minimum number //of non-intersecting brushes. if ( !nocsg ) { brushes = ChopBrushes( brushes ); /* if (create_aas) { brushes = MergeBrushes(brushes); } //end if*/ } //end if //if the conversion is cancelled if ( cancelconversion ) { FreeBrushList( brushes ); return NULL; } //end if //create the actual bsp tree tree = BrushBSP( brushes, mins, maxs ); } //end else //return the tree return tree; } //end of the function ProcessWorldBrushes
//=========================================================================== // creates an .AAS file with the given name // a MAP should be loaded before calling this // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void AAS_Create( char *aasfile ) { entity_t *e; tree_t *tree; double start_time; //for a possible leak file strcpy( source, aasfile ); StripExtension( source ); //the time started start_time = I_FloatTime(); //set the default number of threads (depends on number of processors) ThreadSetDefault(); //set the global entity number to the world model entity_num = 0; //the world entity e = &entities[entity_num]; // ResetBrushBSP(); // if ( writebrushmap ) { char brushMapName[1024]; strcpy( brushMapName, aasfile ); StripExtension( brushMapName ); strcat( brushMapName, "_aas.map" ); OpenBSPBrushMap( brushMapName, CONTENTS_SOLID | CONTENTS_MOVER ); } //process the whole world tree = ProcessWorldBrushes( e->firstbrush, e->firstbrush + e->numbrushes ); //if the conversion is cancelled if ( cancelconversion ) { Tree_Free( tree ); return; } //end if //display BSP tree creation time Log_Print( "BSP tree created in %5.0f seconds\n", I_FloatTime() - start_time ); //prune the bsp tree Tree_PruneNodes( tree->headnode ); //if the conversion is cancelled if ( cancelconversion ) { Tree_Free( tree ); return; } //end if //create the tree portals MakeTreePortals( tree ); //if the conversion is cancelled if ( cancelconversion ) { Tree_Free( tree ); return; } //end if //Marks all nodes that can be reached by entites if ( FloodEntities( tree ) ) { //fill out nodes that can't be reached FillOutside( tree->headnode ); } //end if else { LeakFile( tree ); Error( "**** leaked ****\n" ); return; } //end else //create AAS from the BSP tree //========================================== //initialize tmp aas AAS_InitTmpAAS(); //create the convex areas from the leaves AAS_CreateAreas( tree->headnode ); //free the BSP tree because it isn't used anymore if ( freetree ) { Tree_Free( tree ); } //try to merge area faces AAS_MergeAreaFaces(); //do gravitational subdivision AAS_GravitationalSubdivision(); //merge faces if possible AAS_MergeAreaFaces(); AAS_RemoveAreaFaceColinearPoints(); //merge areas if possible AAS_MergeAreas(); //remove tiny areas AAS_RemoveTinyAreas(); //NOTE: prune nodes directly after area merging AAS_PruneNodes(); //flip shared faces so they are all facing to the same area AAS_FlipSharedFaces(); AAS_RemoveAreaFaceColinearPoints(); //merge faces if possible AAS_MergeAreaFaces(); //merge area faces in the same plane AAS_MergeAreaPlaneFaces(); //do ladder subdivision AAS_LadderSubdivision(); //FIXME: melting is buggy AAS_MeltAreaFaceWindings(); //remove tiny faces AAS_RemoveTinyFaces(); //create area settings AAS_CreateAreaSettings(); //check if the winding plane is equal to the face plane //AAS_CheckAreaWindingPlanes(); // //AAS_CheckSharedFaces(); //========================================== //if the conversion is cancelled if ( cancelconversion ) { Tree_Free( tree ); AAS_FreeTmpAAS(); return; } //end if //store the created AAS stuff in the AAS file format and write the file AAS_StoreFile( aasfile ); //free the temporary AAS memory AAS_FreeTmpAAS(); //display creation time Log_Print( "\nAAS created in %5.0f seconds\n", I_FloatTime() - start_time ); } //end of the function AAS_Create