2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 ==============================================================================
29 Save out name.line for qe3 to read
30 ==============================================================================
38 Finds the shortest possible chain of portals
39 that leads from the outside leaf to a specifically
45 void LeakFile (tree_t *tree)
53 if (!tree->outside_node.occupied)
56 Sys_Printf ("--- LeakFile ---\n");
59 // write the points to the file
61 sprintf (filename, "%s.lin", source);
62 linefile = fopen (filename, "w");
64 Error ("Couldn't open %s\n", filename);
67 node = &tree->outside_node;
68 while (node->occupied > 1)
71 portal_t *p, *nextportal;
75 // find the best portal exit
76 next = node->occupied;
77 for (p=node->portals ; p ; p = p->next[!s])
79 s = (p->nodes[0] == node);
80 if (p->nodes[s]->occupied
81 && p->nodes[s]->occupied < next)
84 nextnode = p->nodes[s];
85 next = nextnode->occupied;
89 WindingCenter (nextportal->winding, mid);
90 fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
93 // add the occupant center
94 GetVectorForKey (node->occupant, "origin", mid);
96 fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
97 Sys_Printf ("%5i point linefile\n", count+1);
107 Finds the shortest possible chain of portals
108 that leads from the outside leaf to a specifically
111 TTimo: builds a polyline xml node
114 xmlNodePtr LeakFile( tree_t *tree ){
120 xmlNodePtr xml_node, point;
122 if ( !tree->outside_node.occupied ) {
126 Sys_FPrintf( SYS_VRB,"--- LeakFile ---\n" );
129 // write the points to the file
131 sprintf( filename, "%s.lin", source );
132 linefile = fopen( filename, "w" );
134 Error( "Couldn't open %s\n", filename );
137 xml_node = xmlNewNode( NULL, "polyline" );
140 node = &tree->outside_node;
141 while ( node->occupied > 1 )
144 portal_t *p, *nextportal;
148 // find the best portal exit
149 next = node->occupied;
150 for ( p = node->portals ; p ; p = p->next[!s] )
152 s = ( p->nodes[0] == node );
153 if ( p->nodes[s]->occupied
154 && p->nodes[s]->occupied < next ) {
156 nextnode = p->nodes[s];
157 next = nextnode->occupied;
161 WindingCenter( nextportal->winding, mid );
162 fprintf( linefile, "%f %f %f\n", mid[0], mid[1], mid[2] );
163 point = xml_NodeForVec( mid );
164 xmlAddChild( xml_node, point );
167 // add the occupant center
168 GetVectorForKey( node->occupant, "origin", mid );
170 fprintf( linefile, "%f %f %f\n", mid[0], mid[1], mid[2] );
171 point = xml_NodeForVec( mid );
172 xmlAddChild( xml_node, point );
173 Sys_FPrintf( SYS_VRB, "%9d point linefile\n", count + 1 );