/* ================ NumberLeafs_r ================ */ void NumberLeafs_r( node_t *node ){ portal_t *p; if ( node->planenum != PLANENUM_LEAF && !node->detail_seperator ) { // decision node node->cluster = -99; NumberLeafs_r( node->children[0] ); NumberLeafs_r( node->children[1] ); return; } // either a leaf or a detail cluster if ( node->contents & CONTENTS_SOLID ) { // solid block, viewpoint never inside node->cluster = -1; return; } FillLeafNumbers_r( node, num_visclusters ); num_visclusters++; // count the portals for ( p = node->portals ; p ; ) { if ( p->nodes[0] == node ) { // only write out from first leaf if ( Portal_VisFlood( p ) ) { num_visportals++; } p = p->next[0]; } else{ p = p->next[1]; } } }
/* ================ NumberLeafs_r ================ */ static void NumberLeafs_r(node_t *node) { portal_t *p; if (!node->contents) { // decision node node->visleafnum = -99; NumberLeafs_r(node->children[0]); NumberLeafs_r(node->children[1]); return; } if (node->contents == CONTENTS_SOLID) { /* solid block, viewpoint never inside */ node->visleafnum = -1; return; } node->visleafnum = num_visleafs++; for (p = node->portals; p;) { /* only write out from first leaf */ if (p->nodes[0] == node) { if (SameContent(p->nodes[0]->contents, p->nodes[1]->contents)) num_visportals++; p = p->next[0]; } else p = p->next[1]; } }
static void NumberLeafs_r (node_t *node) { portal_t *p; if (!node->contents) { // decision node node->visleafnum = -99; NumberLeafs_r (node->children[0]); NumberLeafs_r (node->children[1]); return; } if (node->contents == BSP_CONTENTS_SOLID) { // solid block, viewpoint never inside node->visleafnum = -1; return; } node->visleafnum = num_visleafs++; for (p = node->portals ; p ; ) { if (p->nodes[0] == node) // only write out from first leaf { if (p->winding && PortalSidesVisible (p)) num_visportals++; p = p->next[0]; } else p = p->next[1]; } }
void WritePortalfile (tree_t *tree) { // set the visleafnum field in every leaf and count the total number of portals num_visleafs = 0; num_visportals = 0; NumberLeafs_r (tree->headnode); // write the file printf ("writing %s\n", filename_prt); pf = fopen (filename_prt, "w"); if (!pf) { Error ("Error opening %s", filename_prt); // Not necessary but some compilers are stupid, so f**k it. return; } fprintf (pf, "%s\n", PORTALFILE); fprintf (pf, "%i\n", num_visleafs); fprintf (pf, "%i\n", num_visportals); WritePortalFile_r (tree->headnode); fclose (pf); }
/* ================ NumberLeafs_r ================ */ void NumberLeafs_r(node_t * node) { portal_t *p; if(node->planenum != PLANENUM_LEAF) { // decision node node->cluster = -99; NumberLeafs_r(node->children[0]); NumberLeafs_r(node->children[1]); return; } node->area = -1; if(node->opaque) { // solid block, viewpoint never inside node->cluster = -1; return; } node->cluster = num_visclusters; num_visclusters++; // count the portals for(p = node->portals; p;) { if(p->nodes[0] == node) // only write out from first leaf { if(Portal_Passable(p)) num_visportals++; else num_solidfaces++; p = p->next[0]; } else { if(!Portal_Passable(p)) num_solidfaces++; p = p->next[1]; } } }
/* ================ NumberClusters ================ */ void NumberClusters(tree_t *tree) { num_visclusters = 0; num_visportals = 0; num_solidfaces = 0; Sys_FPrintf (SYS_VRB,"--- NumberClusters ---\n"); // set the cluster field in every leaf and count the total number of portals NumberLeafs_r (tree->headnode); Sys_FPrintf( SYS_VRB, "%9d visclusters\n", num_visclusters ); Sys_FPrintf( SYS_VRB, "%9d visportals\n", num_visportals ); Sys_FPrintf( SYS_VRB, "%9d solidfaces\n", num_solidfaces ); }
/* ================ NumberClusters ================ */ void NumberClusters(tree_t *tree) { num_visclusters = 0; num_visportals = 0; num_solidfaces = 0; qprintf ("--- NumberClusters ---\n"); // set the cluster field in every leaf and count the total number of portals NumberLeafs_r (tree->headnode); qprintf ("%5i visclusters\n", num_visclusters); qprintf ("%5i visportals\n", num_visportals); qprintf ("%5i solidfaces\n", num_solidfaces); }
/* ================ NumberLeafs_r ================ */ void NumberLeafs_r (node_t *node) { portal_t *p; if (!node->contents) { // decision node node->visleafnum = -99; NumberLeafs_r (node->children[0]); NumberLeafs_r (node->children[1]); return; } Draw_ClearWindow (); DrawLeaf (node, 1); if (node->contents == CONTENTS_SOLID) { // solid block, viewpoint never inside node->visleafnum = -1; return; } node->visleafnum = num_visleafs++; for (p = node->portals ; p ; ) { if (p->nodes[0] == node) // only write out from first leaf { if ( (watervis && p->nodes[0]->contents != CONTENTS_SOLID && p->nodes[1]->contents != CONTENTS_SOLID) || (p->nodes[0]->contents == p->nodes[1]->contents) ) num_visportals++; p = p->next[0]; } else p = p->next[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"); }
/* ================ WritePortalfile ================ */ void WritePortalfile (node_t *headnode) { // set the visleafnum field in every leaf and count the total number of portals num_visleafs = 0; num_visportals = 0; NumberLeafs_r (headnode); // write the file printf ("writing %s\n", portfilename); pf = fopen (portfilename, "w"); if (!pf) Error ("Error opening %s", portfilename); fprintf (pf, "%s\n", PORTALFILE); fprintf (pf, "%i\n", num_visleafs); fprintf (pf, "%i\n", num_visportals); WritePortalFile_r (headnode); fclose (pf); }
/* * ================ * WritePortalfile * ================ */ void WritePortalfile(node_t* headnode) { // set the visleafnum field in every leaf and count the total number of portals num_visleafs = 0; num_visportals = 0; NumberLeafs_r(headnode); // write the file pf = fopen(g_portfilename, "w"); if (!pf) { Error("Error writing portal file %s", g_portfilename); } fprintf(pf, "%i\n", num_visleafs); fprintf(pf, "%i\n", num_visportals); WritePortalFile_r(headnode); fclose(pf); Log("BSP generation successful, writing portal file '%s'\n", g_portfilename); }
/* ================ WritePortalfile ================ */ static void WritePortalfile(node_t *headnode) { // set the visleafnum field in every leaf and count the total number of portals num_visleafs = 0; num_visportals = 0; NumberLeafs_r(headnode); // write the file StripExtension(options.szBSPName); strcat(options.szBSPName, ".prt"); PortalFile = fopen(options.szBSPName, "wt"); if (PortalFile == NULL) Message(msgError, errOpenFailed, options.szBSPName, strerror(errno)); fprintf(PortalFile, "PRT1\n"); fprintf(PortalFile, "%i\n", num_visleafs); fprintf(PortalFile, "%i\n", num_visportals); WritePortalFile_r(headnode); fclose(PortalFile); }
/* ================ NumberLeafs_r ================ */ void NumberLeafs_r (node_t *node, int c) { #if 0 portal_t *p; #endif if ( node->planenum != PLANENUM_LEAF ) { // decision node node->cluster = -99; if(node->has_structural_children) { #if 0 if(c >= 0) Sys_FPrintf (SYS_ERR,"THIS CANNOT HAPPEN\n"); #endif NumberLeafs_r (node->children[0], c); NumberLeafs_r (node->children[1], c); } else { if(c < 0) c = num_visclusters++; NumberLeafs_r (node->children[0], c); NumberLeafs_r (node->children[1], c); } return; } node->area = -1; if ( node->opaque ) { // solid block, viewpoint never inside node->cluster = -1; return; } if(c < 0) c = num_visclusters++; node->cluster = c; #if 0 // count the portals for (p = node->portals ; p ; ) { if (p->nodes[0] == node) // only write out from first leaf { if (PortalPassable(p)) num_visportals++; else num_solidfaces++; p = p->next[0]; } else { if (!PortalPassable(p)) num_solidfaces++; p = p->next[1]; } } #endif }