void SaveClusters_r (node_t *node) { if (node->planenum == PLANENUM_LEAF) { dleafs[clusterleaf++].cluster = node->cluster; return; } SaveClusters_r (node->children[0]); SaveClusters_r (node->children[1]); }
/* ================ WritePortalFile ================ */ void WritePortalFile( tree_t *tree ){ char filename[1024]; node_t *headnode; Sys_FPrintf( SYS_VRB, "--- WritePortalFile ---\n" ); headnode = tree->headnode; num_visclusters = 0; num_visportals = 0; FreeTreePortals_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 ); Sys_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 ); Sys_FPrintf( SYS_VRB, "%5i visclusters\n", num_visclusters ); Sys_FPrintf( SYS_VRB, "%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 ); }
/* * @brief */ void WritePortalFile(tree_t *tree) { char filename[MAX_OSPATH]; node_t *head_node; Com_Verbose("--- WritePortalFile ---\n"); head_node = tree->head_node; num_visclusters = 0; num_visportals = 0; FreeTreePortals_r(head_node); MakeHeadnodePortals(tree); CreateVisPortals_r(head_node); // set the cluster field in every leaf and count the total number of portals NumberLeafs_r(head_node); // write the file StripExtension(map_name, filename); strcat(filename, ".prt"); if (!(prtfile = Fs_OpenWrite(filename))) Com_Error(ERR_FATAL, "Error opening %s\n", filename); Fs_Print(prtfile, "%s\n", PORTALFILE); Fs_Print(prtfile, "%i\n", num_visclusters); Fs_Print(prtfile, "%i\n", num_visportals); Com_Verbose("%5i visclusters\n", num_visclusters); Com_Verbose("%5i visportals\n", num_visportals); WritePortalFile_r(head_node); Fs_Close(prtfile); // we need to store the clusters out now because ordering // issues made us do this after writebsp... clusterleaf = 1; SaveClusters_r(head_node); Com_Verbose("--- WritePortalFile complete ---\n"); }