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