2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
5 This file is part of Quake 2 Tools source code.
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, 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 Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
26 ==============================================================================
30 Save out name.line for qe3 to read
31 ==============================================================================
39 Finds the shortest possible chain of portals
40 that leads from the outside leaf to a specifically
44 void LeakFile (tree_t *tree)
52 if (!tree->outside_node.occupied)
55 qprintf ("--- LeakFile ---\n");
58 // write the points to the file
60 sprintf (filename, "%s.lin", source);
61 linefile = fopen (filename, "w");
63 Error ("Couldn't open %s\n", filename);
66 node = &tree->outside_node;
67 while (node->occupied > 1)
70 portal_t *p, *nextportal;
74 // find the best portal exit
75 next = node->occupied;
76 for (p=node->portals ; p ; p = p->next[!s])
78 s = (p->nodes[0] == node);
79 if (p->nodes[s]->occupied
80 && p->nodes[s]->occupied < next)
83 nextnode = p->nodes[s];
84 next = nextnode->occupied;
88 WindingCenter (nextportal->winding, mid);
89 fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
92 // add the occupant center
93 GetVectorForKey (node->occupant, "origin", mid);
95 fprintf (linefile, "%f %f %f\n", mid[0], mid[1], mid[2]);
96 qprintf ("%5i point linefile\n", count+1);