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
21 ----------------------------------------------------------------------------------
\r
23 This code has been altered significantly from its original form, to support
\r
24 several games based on the Quake III Arena engine, in the form of "Q3Map2."
\r
26 ------------------------------------------------------------------------------- */
\r
41 ==============================================================================
\r
43 LEAK FILE GENERATION
\r
45 Save out name.line for qe3 to read
\r
46 ==============================================================================
\r
54 Finds the shortest possible chain of portals
\r
55 that leads from the outside leaf to a specifically
\r
58 TTimo: builds a polyline xml node
\r
61 xmlNodePtr LeakFile (tree_t *tree)
\r
65 char filename[1024];
\r
68 xmlNodePtr xml_node, point;
\r
70 if (!tree->outside_node.occupied)
\r
73 Sys_FPrintf (SYS_VRB,"--- LeakFile ---\n");
\r
76 // write the points to the file
\r
78 sprintf (filename, "%s.lin", source);
\r
79 linefile = fopen (filename, "w");
\r
81 Error ("Couldn't open %s\n", filename);
\r
83 xml_node = xmlNewNode (NULL, "polyline");
\r
86 node = &tree->outside_node;
\r
87 while (node->occupied > 1)
\r
90 portal_t *p, *nextportal;
\r
94 // find the best portal exit
\r
95 next = node->occupied;
\r
96 for (p=node->portals ; p ; p = p->next[!s])
\r
98 s = (p->nodes[0] == node);
\r
99 if (p->nodes[s]->occupied
\r
100 && p->nodes[s]->occupied < next)
\r
103 nextnode = p->nodes[s];
\r
104 next = nextnode->occupied;
\r
108 WindingCenter (nextportal->winding, mid);
\r
109 fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
\r
110 point = xml_NodeForVec(mid);
\r
111 xmlAddChild(xml_node, point);
\r
114 // add the occupant center
\r
115 GetVectorForKey (node->occupant, "origin", mid);
\r
117 fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
\r
118 point = xml_NodeForVec(mid);
\r
119 xmlAddChild(xml_node, point);
\r
120 Sys_FPrintf( SYS_VRB, "%9d point linefile\n", count+1);
\r