1 /* -------------------------------------------------------------------------------
3 Copyright (C) 1999-2007 id Software, Inc. and contributors.
4 For a list of contributors, see the accompanying CONTRIBUTORS file.
6 This file is part of GtkRadiant.
8 GtkRadiant is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 GtkRadiant is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with GtkRadiant; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 ----------------------------------------------------------------------------------
24 This code has been altered significantly from its original form, to support
25 several games based on the Quake III Arena engine, in the form of "Q3Map2."
27 ------------------------------------------------------------------------------- */
42 ==============================================================================
46 Save out name.lin for qe3 to read
47 ==============================================================================
55 Finds the shortest possible chain of portals
56 that leads from the outside leaf to a specifically
59 TTimo: builds a polyline xml node
62 xmlNodePtr LeakFile( tree_t *tree, const char *filename ){
67 xmlNodePtr xml_node, point;
69 if ( !tree->outside_node.occupied ) {
73 Sys_FPrintf( SYS_VRB,"--- LeakFile ---\n" );
76 // write the points to the file
78 linefile = fopen( filename, "w" );
80 Error( "Couldn't open %s\n", filename );
83 xml_node = xmlNewNode( NULL, (xmlChar*)"polyline" );
86 node = &tree->outside_node;
87 while ( node->occupied > 1 )
90 portal_t *p, *nextportal = NULL;
91 node_t *nextnode = NULL;
94 // find the best portal exit
95 next = node->occupied;
96 for ( p = node->portals ; p ; p = p->next[!s] )
98 s = ( p->nodes[0] == node );
99 if ( p->nodes[s]->occupied
100 && p->nodes[s]->occupied < next ) {
102 nextnode = p->nodes[s];
103 next = nextnode->occupied;
107 WindingCenter( nextportal->winding, mid );
108 fprintf( linefile, "%f %f %f\n", mid[0], mid[1], mid[2] );
109 point = xml_NodeForVec( mid );
110 xmlAddChild( xml_node, point );
113 // add the occupant center
114 GetVectorForKey( node->occupant, "origin", mid );
116 fprintf( linefile, "%f %f %f\n", mid[0], mid[1], mid[2] );
117 point = xml_NodeForVec( mid );
118 xmlAddChild( xml_node, point );
119 Sys_FPrintf( SYS_VRB, "%9d point linefile\n", count + 1 );