//=========================================================================== // // 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
//=========================================================================== // The incoming brush list will be freed before exiting // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== tree_t *BrushBSP( bspbrush_t *brushlist, vec3_t mins, vec3_t maxs ) { int i, c_faces, c_nonvisfaces, c_brushes; bspbrush_t *b; node_t *node; tree_t *tree; vec_t volume; // vec3_t point; Log_Print( "-------- Brush BSP ---------\n" ); tree = Tree_Alloc(); c_faces = 0; c_nonvisfaces = 0; c_brushes = 0; c_totalsides = 0; for ( b = brushlist; b; b = b->next ) { c_brushes++; volume = BrushVolume( b ); if ( volume < microvolume ) { Log_Print( "WARNING: entity %i, brush %i: microbrush\n", b->original->entitynum, b->original->brushnum ); } //end if for ( i = 0 ; i < b->numsides ; i++ ) { if ( b->sides[i].flags & SFL_BEVEL ) { continue; } if ( !b->sides[i].winding ) { continue; } if ( b->sides[i].texinfo == TEXINFO_NODE ) { continue; } if ( b->sides[i].flags & SFL_VISIBLE ) { c_faces++; } //end if else { c_nonvisfaces++; //if (create_aas) b->sides[i].texinfo = TEXINFO_NODE; } //end if } //end for c_totalsides += b->numsides; AddPointToBounds( b->mins, tree->mins, tree->maxs ); AddPointToBounds( b->maxs, tree->mins, tree->maxs ); } //end for Log_Print( "%6i brushes\n", c_brushes ); Log_Print( "%6i visible faces\n", c_faces ); Log_Print( "%6i nonvisible faces\n", c_nonvisfaces ); Log_Print( "%6i total sides\n", c_totalsides ); c_active_brushes = c_brushes; c_nodememory = 0; c_brushmemory = 0; c_peak_brushmemory = 0; c_nodes = 0; c_nonvis = 0; node = AllocNode(); //volume of first node (head node) node->volume = BrushFromBounds( mins, maxs ); // tree->headnode = node; //just get some statistics and the mins/maxs of the node numrecurse = 0; // qprintf("%6d splits", numrecurse); tree->headnode->brushlist = brushlist; BuildTree( tree ); //build the bsp tree with the start node from the brushlist // node = BuildTree_r(node, brushlist); //if the conversion is cancelled if ( cancelconversion ) { return tree; } qprintf( "\n" ); Log_Write( "%6d splits\r\n", numrecurse ); // Log_Print("%6i visible nodes\n", c_nodes/2 - c_nonvis); // Log_Print("%6i nonvis nodes\n", c_nonvis); // Log_Print("%6i leaves\n", (c_nodes+1)/2); // Log_Print("%6i solid leaf nodes\n", c_solidleafnodes); // Log_Print("%6i active brushes\n", c_active_brushes); if ( numthreads == 1 ) { // Log_Print("%6i KB of node memory\n", c_nodememory >> 10); // Log_Print("%6i KB of brush memory\n", c_brushmemory >> 10); // Log_Print("%6i KB of peak brush memory\n", c_peak_brushmemory >> 10); // Log_Print("%6i KB of winding memory\n", WindingMemory() >> 10); // Log_Print("%6i KB of peak winding memory\n", WindingPeakMemory() >> 10); Log_Print( "%6i KB of peak total bsp memory\n", c_peak_totalbspmemory >> 10 ); } //end if