//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void Tree_FreePortals_r( node_t *node ) { portal_t *p, *nextp; int s; // free children if ( node->planenum != PLANENUM_LEAF ) { Tree_FreePortals_r( node->children[0] ); Tree_FreePortals_r( node->children[1] ); } // free portals for ( p = node->portals; p; p = nextp ) { s = ( p->nodes[1] == node ); nextp = p->next[s]; RemovePortalFromNode( p, p->nodes[!s] ); #ifdef ME if ( p->winding ) { freedtreemem += MemorySize( p->winding ); } freedtreemem += MemorySize( p ); #endif //ME FreePortal( p ); } node->portals = NULL; } //end of the function Tree_FreePortals_r
/* ================ WritePortalFile ================ */ void WritePortalFile( tree_t *tree ) { char filename[1024]; node_t *headnode; qprintf( "--- WritePortalFile ---\n" ); headnode = tree->headnode; num_visclusters = 0; num_visportals = 0; Tree_FreePortals_r( headnode ); MakeHeadnodePortals( tree ); CreateVisPortals_r( headnode ); // set the cluster field in every leaf and count the total number of portals NumberLeafs_r( headnode ); // write the file sprintf( filename, "%s.prt", source ); printf( "writing %s\n", filename ); pf = fopen( filename, "w" ); if ( !pf ) { Error( "Error opening %s", filename ); } fprintf( pf, "%s\n", PORTALFILE ); fprintf( pf, "%i\n", num_visclusters ); fprintf( pf, "%i\n", num_visportals ); qprintf( "%5i visclusters\n", num_visclusters ); qprintf( "%5i visportals\n", num_visportals ); WritePortalFile_r( headnode ); fclose( pf ); // we need to store the clusters out now because ordering // issues made us do this after writebsp... clusterleaf = 1; SaveClusters_r( headnode ); }
//=========================================================================== // // Parameter: - // Returns: - // Changes Globals: - //=========================================================================== void Tree_Free( tree_t *tree ) { //if no tree just return if ( !tree ) { return; } // freedtreemem = 0; // Tree_FreePortals_r( tree->headnode ); Tree_Free_r( tree->headnode ); #ifdef ME freedtreemem += MemorySize( tree ); #endif //ME FreeMemory( tree ); #ifdef ME Log_Print( "freed " ); PrintMemorySize( freedtreemem ); Log_Print( " of tree memory\n" ); #endif //ME } //end of the function Tree_Free